Forum Moderators: open

Message Too Old, No Replies

window handler events

         

woldie

12:14 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



Hi,

When you click on a link it opens up a new window (child window), however what i want to do is when you click on a link within the open window (child), it closes the child window and takes you back to the page specified within the link for example the home page in the parent window. Does that make sense?

Any ideas? I've been scouring the web but I can't seem to find the code I'm looking for.

Thanks.

Alternative Future

12:44 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi woldie,

This should do what you are trying to do:

<a href="javascript: opener.location.href = 'your_calling_url'; window.close();"></a>

hth,

-gs

woldie

12:59 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



Thanks Alternative_Future,

That did work, however from a SEO point of view, is there is some code which is search engine friendly?

Thanks

Alternative Future

1:07 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No problem woldie,

I don't think there is a way of completing what you are trying to do without the use of JavaScript, and I assume this is what you mean by saying Search Engine friendly by eliminating the JavaScript.
I might be wrong and if this is the case am sure some other members shall correct me and put you right ;)

-gs

woldie

1:36 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



Thanks for the reponse. what I mean by SEO friendly is not to eliminate the JavaScript but in the way of show the '<a href='your_calling_url' then JavaScript code afterwards, since the spider will be able to recognise the <a href bit first.

I'm sure some other members will put their ideas into the ring.

Cheers.

Alternative Future

1:48 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could override the href with the onclick event as follows:

<a onclick="javascript: opener.location.href = 'test.html'; window.close()" href="test.html">click</a>

this way the search engine finds the new page with the href tag but user intervention uses the onclick event and closes the open window.

Is this what you mean to achieve?

-gs

woldie

2:03 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



Thats the one...

That works well, so I have a SEO friendly JavaScript code in which spiders can be able to follow the link, thanks for your help.

This is also works in Netscape as well, which is a added bonus.

Cheers.

BlobFisk

2:10 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't forget that by adding return false; you can override the default browser behaviour:

<a onclick="javascript: opener.location.href = 'test.html'; window.close(); return false" href="test.html">click</a>

This would be more applicable to javascript that opens a link/window via JavaScript. By using return false; you can link using JavaScript, but still make the link spider friendly.

woldie

2:27 pm on Oct 29, 2003 (gmt 0)

10+ Year Member



I see, yes that would be a wise move, thanks Blobfisk.

Thanks.

korkus2000

2:39 pm on Oct 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



BTW you should not need the javascript: in an onClick attribute. Javascript is considered the default page language.