JavierVera
asked on
Jquery or Javascript alternative to window.open to get a different target
Hi guys,
Quick, heh.
I am trying to achieve the following:
1- I have a <a> html tag in the jsp page.
2- I want to execute the <a> LIKE with an "onClick" when document ready.
For this i have done the following:
<a id="redirect" href="<%= strToGo %>" target="_blank">aaaa</a>
The main purpose for this is to achieve a new window opened when i load the page.
I don't want my url to be blocked by the popup blocker <--
Please any advice would be great.
Quick, heh.
I am trying to achieve the following:
1- I have a <a> html tag in the jsp page.
2- I want to execute the <a> LIKE with an "onClick" when document ready.
For this i have done the following:
<a id="redirect" href="<%= strToGo %>" target="_blank">aaaa</a>
<script>
$(document).ready(function() {
$(redirect).click();
});
</script>
The main purpose for this is to achieve a new window opened when i load the page.
I don't want my url to be blocked by the popup blocker <--
Please any advice would be great.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
isn't Jquery or javascript smart enough to validate a sort of valid location for allowing this? actually what i'd like is some sort of advice to achieve the requeriment. So far i have read several guys claiming the same as mankowitz said yet none gave any idea to achieve or solve the issue heh. if the scripts (jquery etc) doesnt provide anything to validate then i guess i am done with this ? :)
Look at this fiddle
http://jsfiddle.net/GaryC123/L0y59q9w/
A simple window.open for Google and works fine
http://jsfiddle.net/GaryC123/L0y59q9w/
A simple window.open for Google and works fine
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Gary, thank you really much for your time.
But i belive the browser blocks the window due the use of 'window.open'.
I have found this post, yet i have no idea how to implement it on the jsp page i am using.
LINK TO CONCURRENT SITE REMOVED
But i belive the browser blocks the window due the use of 'window.open'.
I have found this post, yet i have no idea how to implement it on the jsp page i am using.
LINK TO CONCURRENT SITE REMOVED
function eventFire(el, etype){
if (el.fireEvent) {
el.fireEvent('on' + etype);
} else {
var evObj = document.createEvent('Events');
evObj.initEvent(etype, true, false);
el.dispatchEvent(evObj);
}
}
The code above will not do what you want if they have all popups blocked - there is nothing you can do in code to override it
The only solution is as I have above and you have to leave it up to the individual user to allow it.
The only solution is as I have above and you have to leave it up to the individual user to allow it.
ASKER
thing is that i do actions in a page very very very different so i must consider use a middle jsp page to do this sort of bridge, yet i hope it will work if not i will explain the workaround when done.
thank you!
thank you!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for the time
It cannot simulate a person actually clicking the link.
There is no reason a simple window.open shouldn't work