This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Webmaster forum > June 2005 > javascript links





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author javascript links
Alex

2005-06-24, 7:31 pm

Hello, could anyone please help me. When using javascript for a link I put a
# in the link, like <a href="#"
but when someone opens a new window, the old window flicks back to the top,
is there any way of stopping this?

Thanks for any help

Alex


David Dorward

2005-06-24, 7:31 pm

Alex wrote:

> Hello, could anyone please help me. When using javascript for a link I put
> a # in the link, like <a href="#"


Don't do that:

<a href="something.html" onclick="somefunction();return false">
where something.html is meaningful to the non-javascript
capable, is nearly always preferable.

-- http://jibbering.com/faq/#FAQ4_24

> but when someone opens a new window, the old window flicks back to the
> top, is there any way of stopping this?


Not using popup windows is probably the best solution; they are nearly
always a poor design choice. Failing that, see:
http://www.allmyfaqs.com/faq.pl?Console_window

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Dylan Parry

2005-06-24, 7:31 pm

Alex wrote:
> Hello, could anyone please help me. When using javascript for a link
> I put a # in the link, like <a href="#" but when someone opens a new
> window, the old window flicks back to the top, is there any way of
> stopping this?


Use code like:

<a href="/page.html"
onclick="window.open('/page.html','','width=400,height=400'); return
false;">link text</a>

That way, if the user has JS disabled, or popups blocked, then they
/should/ get the new page loaded in the same window/tab that the
original site was in. The "return false;" bit simply stops the original
page from jumping back to the top.

--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references
Norman L. DeForest

2005-06-24, 7:31 pm


On Fri, 24 Jun 2005, Alex wrote:

> Hello, could anyone please help me. When using javascript for a link I put a
> # in the link, like <a href="#"
> but when someone opens a new window, the old window flicks back to the top,
> is there any way of stopping this?
>
> Thanks for any help


Instead of just using something like this:
<a href="#" onclick="OpenWindow('foo.html');">foo</a>
add a "return(false);" to the java script:
<a href="#" onclick="OpenWindow('foo.html');return(false);">foo</a>

This should suppress the href="#" for browsers with JavaScript on.

Something like this would keep all browsers at approximately the
current location (within one screen page) even if they have JavaScript
off or the browser doesn't support java script:
<a name="foolabel">&nbsp;</a>
<a href="#foolabel"
onclick="OpenWindow('foo.html');return(false);">foo</a>

--
Windows is *not* a "Toy OS".
/me desperately trying to hide the URL for the screenshot of my desktop
http://www.chebucto.ns.ca/~af380/te...Jun-22-2005.gif

Brian Cryer

2005-06-24, 7:31 pm

"Norman L. DeForest" <af380@chebucto.ns.ca> wrote in message
news:Pine.GSO.3.95.iB1.0.1050624113913.16651A-100000@halifax.chebucto.ns.ca...
>
> --
> Windows is *not* a "Toy OS".
> /me desperately trying to hide the URL for the screenshot of my desktop
> http://www.chebucto.ns.ca/~af380/te...Jun-22-2005.gif


Very good.

Brian.


Alex

2005-06-24, 7:31 pm

Thanks for the help everyone.

"Norman L. DeForest" <af380@chebucto.ns.ca> wrote in message
news:Pine.GSO.3.95.iB1.0.1050624113913.16651A-100000@halifax.chebucto.ns.ca...
>
> On Fri, 24 Jun 2005, Alex wrote:
>
>
> Instead of just using something like this:
> <a href="#" onclick="OpenWindow('foo.html');">foo</a>
> add a "return(false);" to the java script:
> <a href="#" onclick="OpenWindow('foo.html');return(false);">foo</a>
>
> This should suppress the href="#" for browsers with JavaScript on.
>
> Something like this would keep all browsers at approximately the
> current location (within one screen page) even if they have JavaScript
> off or the browser doesn't support java script:
> <a name="foolabel">&nbsp;</a>
> <a href="#foolabel"
> onclick="OpenWindow('foo.html');return(false);">foo</a>
>
> --
> Windows is *not* a "Toy OS".
> /me desperately trying to hide the URL for the screenshot of my desktop
> http://www.chebucto.ns.ca/~af380/te...Jun-22-2005.gif
>



Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews