PDA

View Full Version : Detect "Open Link in New Window"


Evlich
12-15-2002, 03:42 AM
Hello, I am working on a site and i have a lot of links that call javascripts instead of actually linking to a different page; howevver, I run into problems when people say "open link in new window". Is there a way to detect teh open link in new window action for IE and NS? Thanks a lot.

whammy
12-15-2002, 05:25 AM
Your question does not compute. :confused:

Evlich
12-15-2002, 05:34 AM
Ok, if you have a link, then you can right click on it and select "Open in New Window." What I want to do is detect when the user selects "Open in New Window" rather than just clicking on the link so that if it runs a javascript I can open a new window and do something with the new window.

whammy
12-15-2002, 05:36 AM
Hmm, as far as I know you can't do anything about that at all... I could possibly be wrong though.

brothercake
12-15-2002, 05:41 AM
I concur - don't think there's any way you can know. Why do you want to know? Perhaps there's another way to acheive your bottom line?

whammy
12-15-2002, 05:43 AM
Yup, like I always say... "What are you trying to accomplish?" - and by that I mean the "big picture" - not what you're trying to accomplish with your current code.

Evlich
12-15-2002, 05:45 AM
Well, say for instance I have a link that invokes a javascript. If I do "Open in New Window" then I end up opening a blank window and I get a script error. Can anyone think of a way to detect that and instead of trying to invoke the javascript to load a page in that new window.

chrismiceli
12-15-2002, 06:22 AM
why not use the onClick event handler of the a href like this
<a href="#" onClick="javascriptfunction">hi</a>

brothercake
12-15-2002, 09:18 AM
if you use do it like this, it doesn't matter which button is clicked and you never get "#" in your address bar:

<script type="text/javascript">

function doSomething() {
alert("something");
return false;
}

</script>


<p><a href="#" onmousedown="return doSomething()">doSomething()</a>

Evlich
12-15-2002, 06:59 PM
That makes it so that it doesn't pop up another window, but what if I want to make it so that if they do want to do open in new window then it will open a new window with the same page in it. For instance if my link changed the caption in a div or something, is there a way that i could pull up the same window, but with the caption changed in the new window? Thanks a lot.