auto close url
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2024 08:39 AM
Hi,
I have a button. after clicking it will download a iCalenter type file. then it is going to another url. I want to autoclose that redirection. tried not working.
HTML:
<a href = "{{data.addToCalender}}" target="_blank" onclick="c.close()">
<button class="btn btn-primary action-btn pull-right">
Add to calendar
</button></a>
client Script:
c = this;
c.close = function(){
setTimeout(window.close,1000);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2024 08:50 AM
Hi @Rosy14
It seems like you're trying to close the window after clicking on a button, but it's not working as expected.
Firstly, ensure that your HTML markup is correct. It's better not to nest a button inside an anchor tag (<a>). Instead, you can directly attach the onclick event to the button itself.
Here's how you can modify your code:
HTML
<button class="btn btn-primary action-btn pull-right" onclick="closeWindowAndRedirect('{{data.addToCalender}}')">
Add to calendar
</button>
Client Script
var c = this;
c.closeWindowAndRedirect = function(url) {
window.open(url, '_blank');
setTimeout(function() { window.close(); }, 1000);
};
Try this and let me know if it works.
Tanuj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2024 11:16 PM
Still not working. noting happening after clicking the button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2024 03:27 AM
Hi @Rosy14 ,
Can you do a gs.info on the client side or a alert to confirm if the onclick is working correctly with the parameters passed.
Then share a snapshot with the code you have to help me debug..
Tanuj