View Full Version : Javascript Links

05-08-2003, 01:21 PM
Hi there,

Would anyone be kind enough to tell me how you make javascript links please? Like Chris links to other pages, but the link actually reads on this site (if ya get me)!


05-08-2003, 01:42 PM
a javascript link can be made any number of ways

<a href = "javascript:void" onclick = "window.open(url);">

would be one.

05-08-2003, 01:45 PM

Will this mean my PR will not go down if I am linking to other sites please?

05-08-2003, 03:20 PM
If you link like that, no it will not go down.

05-09-2003, 08:13 AM
Thanks Chris...

I have the following:

<a href = "javascript:void" onclick = "window.open('links.html');" class="cssclass" title="title of link">LINKS</a>

Would that be OK please?

Sorry for all the bother...

05-09-2003, 10:30 AM

05-09-2003, 10:36 AM
Thanks for all the help:)

09-02-2003, 03:51 AM
Hi all,

It's a new issue but since there are may common points i thought it is a good idea to post here.

Will search engines follow such a link?

<script type="text/javascript">
function loadUrl(newLocation)
window.location.href = newLocation;

<a href="http://somesite.com" onclick="loadUrl(this.href); return false;">link-1</a>

What is your opinions?

Thanks in advance for any ideas

09-02-2003, 05:29 AM

09-02-2003, 05:35 AM
what about this one?

<a href="java script:void" class="menu" onclick="window.location.href='http://www.domain.com'; return false;">domain.com</a>

09-02-2003, 07:25 AM
that should work.

A better way is to do

<script language = "javascript">
document.write('<a hre' + 'f = "ht' + 'tp://ww' + 'w.dom' + 'ain.com">text</a>');

If you really want to use javascript. There is nothing there that a search engine can parse a url from.

09-02-2003, 10:40 PM
it worked! many thanks

(for other readers there is a typo in Chris' last post)
not <script language = "javascript>
<script language = "javascript">

just wanted to note it

10-27-2003, 07:42 PM
how do u create a javascript link ? without opening another window ?

i tried this
<a href = "javascript:void" onclick = "window.open(url);">

but it seems to come up a error for me

10-27-2003, 07:43 PM
that'd still open another window,

using top.href or self.href should work without opening another window.

12-12-2003, 05:40 AM
Bringing an old topic back...

I hope to have a javascript menu as top navigation, with the rest being text links. It won't really matter as all the important pages will be linked to with text links. So my question is would the following be ok? Or would it pass PR on?

<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','images/b1r.jpg',1)">
<img src="images/b1.jpg" name="Image10" width="95" height="19" border="0"></a>
<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image4','','images/b2r.jpg',1)">
<img src="images/b2.jpg" name="Image4" width="70" height="19" border="0"></a>


12-12-2003, 11:58 AM
I edited your post so we didn't have horizontal scroll.

That should not pass PR. However it doesn't look like it'd function as a link either.

12-12-2003, 02:53 PM
Thanks for editting it:)

I've not tried it for functioning yet, I bought a Templatemonster template so that could be the reason:)

Anyway thanks Chris.

12-12-2003, 03:27 PM
Oh yeah and just on the topic of javascript links...

if you are using '(<a hre + 'f="http://") could you change it into <a hre + f="http://"). Like I don't need/want the document.write bit there, so would the way I show be the right way of going about things?

12-12-2003, 05:46 PM
I just use the following...

<a href="#" onclick="window.open('http://www.url.com')">Text</a>

Ofcoarse, thats if you want to open the link in a new window.
roor bong (http://roorbongs.org)

12-25-2003, 09:34 AM
Originally posted by Mike
if you are using '(<a hre + 'f="http://") could you change it into <a hre + f="http://"). Like I don't need/want the document.write bit there, so would the way I show be the right way of going about things?

Huh? Your saying you dont want the document.write bit? I dont quite understand that - thats how JS writes to the page.

You use JS to write the code so that you can break up the "<a href=" so Google doesnt realise its a link.