views:

53

answers:

2

I am working on a CMS site that uses dynamic navigation. There is one link on the site that I would like to be able to open in a new window. However, since this is a dynamic environment I can't add the standard, target="_blank" to the link.

Resorting to Javascript I tried the following:

<script type="text/javascript">
window.open ('http://www.foo.edu/education/global-health-courses', 'newwindow',   config='height=800, width=700')
 </script>

Unfortunately, this does not work properly. I could use a little Javascript magic to have this work properly.

Thanks.

A: 

How about your browser configuration? In my case it works, maybe you have some adblock/popup limitations?

You can also try with jQuery which supports more browsers than plain javascript (usually)...

$('a[href^="http://"]').attr("target", "_blank");
bluszcz
I forgot to include the fact that this needs to be tied to a specific link in the navigation.
fmz
This answer was close, but I got the full answer here:http://stackoverflow.com/questions/2095968/jquery-to-open-link-in-new-window-not-working/2096025#2096025
fmz
sorry, i was not enough detailed :)
bluszcz
A: 

Simply use the proper window name and you should be fine:

<script type="text/javascript"> 
window.open ("http://www.foo.edu/", "_blank", "height=800, width=700");
</script> 
Paulo Santos
Hi Paulo, I just realized that I missed a very, very important aspect of this problem. I need this to be associated with one specific link in the navigation. How do I do that part?
fmz
If you can access the onClick property, simply put the code in it. However, if you don't, but have access to JQuery, use it.
Paulo Santos
you can see jquery example in my answer.if you have link:<a id="mylink" href="http://stackoverflow.com">SO</a> you can use$("#mylink").attr("target", "_blank");
bluszcz