PDA

View Full Version : Using "Open offsite links in new window" with other javascript



jimmiejo
05-31-2008, 09:30 PM
I've been using this Dynamic Drive script (http://www.dynamicdrive.com/dynamicindex8/newwindow2.htm) for a while now without any issues.

I recently added a plugin to my Wordpress installation that allows me to bookmark posts on-site using javascript. The link to bookmark is as follows:


<a title="Bookmark this post" href="javascript:addFavorites('<?php the_title(); ?>','<?php the_permalink() ?>');">Bookmark</a>

When the "open links in new window' box is checked, the bookmark javascript still works fine in Safari, sliding down a confirmation box to bookmark the post. But in Firefox, when the new window box is checked, and I try to bookmark a post with the link above, it opens a new blank window and does nothing with the bookmark script.

Is there any way to include that javascript:addFavorites to new_window.js' excluded domains list so that those links don't open in a new window/tab in Firefox? Or is there another way I might be able to fix this issue?

Thanks in advance :)

ddadmin
06-01-2008, 07:43 AM
Which "open links in new window" script on DD are you experiencing this conflict with? Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

jscheuer1
06-01-2008, 11:37 AM
Or this would probably work, without needing to alter the new window script:


<a title="Bookmark this post" href="<?php the_permalink() ?>"
onclick="addFavorites('<?php the_title(); ?>','<?php the_permalink() ?>');return false;">Bookmark</a>

jimmiejo
06-01-2008, 03:03 PM
Sorry, I included the link on the text for "Dynamic Drive script" but should have typed it in plain text. Here's the one I'm referring to:

Script: Open offsite links in new window
http://www.dynamicdrive.com/dynamicindex8/newwindow2.htm

jscheuer1, I gave the ;return false; a try and that didn't work. Was able to test the conflict in IE last night, and it's the same as Firefox (javascript opens in new window). Safari is still the only one that works.

jscheuer1
06-01-2008, 06:14 PM
Look at my post again. There is more to it than just adding return false. The href has been changed as well, and the event has been hard coded to the onclick, rather than being in the href. Basically, what you need to do is give the link an href value that will not be seen as off site. I am assuming that the value:


<?php the_permalink() ?>

I used there would do so. You could also just make it to the root of the domain, as long as you have that excluded in the new windows script. But you probably did other things differently than what I had in my post, because with an onclick event and return false, the link shouldn't fire at all.

Did you setup the domain here:


excludedomains: ["dynamicdrive.com", "google.com"]

?

Or, you could forget about using a link at all:


<span title="Bookmark this post"
onclick="addFavorites('<?php the_title(); ?>','<?php the_permalink() ?>');">Bookmark</span>

That way, at least the link wouldn't be the issue. If there is still a problem after that, there is something else wrong.

What script are you using for the bookmark?

Please post a link to the page on your site that contains the problematic code so we can check it out.

jimmiejo
06-01-2008, 09:58 PM
I apologize jscheuer1. I was in a rush and didn't notice your initial changes made to my link code. I now copied and pasted it as you wrote it and it works like a charm in all browsers.

A huge thanks to you, and again, sorry for making you type all you did in your last reply -- your first solution did the trick.

Thanks a ton :)