Closed Thread Icon

Preserved Topic: Opening a new window without broken links in old browsers Pages that link to <a href="https://ozoneasylum.com/backlink?for=17787" title="Pages that link to Preserved Topic: Opening a new window without broken links in old browsers" rel="nofollow" >Preserved Topic: Opening a new window without broken links in old browsers\

 
Author Thread
jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 07-14-2000 18:48

Just wondering if anyone knows how to use javascript to open a new window with a URL while maintaining link functionality for non-javascript browsers. Basically I want to keep the addy in the href of the <a> tag, but have it not open the window in the original window IF javascript works and opens the new window. Make sense? Is this possible?

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 07-14-2000 19:27

On the page that the window is linked to, use this code:

<script language="JavaScript">
<!--
document.write('Your browser supports JavaScript! <a href="JavaScript: void OpenWindow();">Click here</a>!');
--> Your browser doesn't support JavaScript.
<!-- --> <a href="mypage.htm">Click here</a>.
</script>

JavaScript considers <!-- a comment tag, so anything after it on the same line will be ignored by the Script, but if the browser doesn't support JavaScript, then it will read the whole thing like it's HTML, and the second message will appear. See?

-Slime

"Windows: Just another pane in the glass."

[This message has been edited by Slime (edited 14-07-2000).]

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 07-17-2000 19:37

Hmm.

I think what you are looking for is something like this.

<A HREF="whatever.htm" TARGET="NEW" onClick="whatever(); return false">Link</A>

Here is what this does, if the browser does not support JS, the link works like normal, opens the link in a new window.

If JS is enabled it will run the whatever() function. and the "return false" nullifies the link. the whatever function can open a new window or run any other kind of JS.


Walking the Earth like Kane

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 07-17-2000 20:13

Yeah... that'll work too. =) Always looking for the simple ways to do things, huh? hah =)

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 07-18-2000 18:55

Thanks for the responses guys. Had no idea u could open a new window without javascript...

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 07-18-2000 20:15

By the way, in case you're interested in the target="" thing:

The target attribute can also be used for frames, when the frames are named. The links will open in the frame targeted.

When the target attribute contains a name that is not the name of a frame, then it will open a new window with that name. When another link is clicked with the same target attribute, it will open it in that same window.

If, however, the target="_blank", then the page will open in a new window that is *not* pre-named. You can click the link again, and it will open yet *another* window. You can click the same link 500 times and it will open 500 windows.

See?

« BackwardsOnwards »

Show Forum Drop Down Menu