Go Back   Trackpads Community > General Discussions > Computer and Technology > Web Design

Web Design Forums and discussions on webdesign

Web Design

Reply
 
LinkBack Thread Tools
Old 06-24-2005, 12:00   #1 (permalink)
Alex
Civilians

 
Default javascript links

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


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Trackpads Information
Click to Visit
Old 06-24-2005, 12:00   #2 (permalink)
David Dorward
Civilians

 
Default Re: javascript links

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
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-24-2005, 12:00   #3 (permalink)
Dylan Parry
Civilians

 
Default Re: javascript links

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
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-24-2005, 12:00   #4 (permalink)
Norman L. DeForest
Civilians

 
Default Re: javascript links


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 javascript:
<a href="#" onclick="OpenWindow('foo.html');return(false);">fo o</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 javascript:
<a name="foolabel">&nbsp;</a>
<a href="#foolabel"
onclick="OpenWindow('foo.html');return(false);">fo o</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/tem...un-22-2005.gif

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-24-2005, 16:00   #5 (permalink)
Brian Cryer
Civilians

 
Default Re: javascript links

"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/tem...un-22-2005.gif


Very good.

Brian.


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-24-2005, 16:00   #6 (permalink)
Alex
Civilians

 
Default Re: javascript links

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:
>
>> 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 javascript:
> <a href="#" onclick="OpenWindow('foo.html');return(false);">fo o</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 javascript:
> <a name="foolabel">&nbsp;</a>
> <a href="#foolabel"
> onclick="OpenWindow('foo.html');return(false);">fo o</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/tem...un-22-2005.gif
>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Links ... Links ... Links (For Katrina) Woodmonkey Chit-Chat 9 09-17-2005 01:29
Javascript Error sfim@iamotelephone.com Web Design 5 09-09-2005 00:00
Re: A little experiment: CSS/JavaScript HC Web Design 2 05-18-2005 00:00
Get-around for Javascript and Win XP SP2 problems Laphan Web Design 6 11-21-2004 19:00
Javascript checkbox Valérie Schüpbach Web Design 0 07-23-2004 15:05


Community Information
Options
Quick Options
Trackpads Non-Commercial Ad
Copyright Information Click to Visit
Time
Server Time
All times are GMT -4. The time now is 20:43.
Copyright
Copyright Information
The header is based off of work by Vipixel.com and modified by this site. Trackpads and the Trackpads Logo are both Registered Trademarks of Jason Edwards and cannot be used without prior written permission.  The only exception is as a link back to this site. Trackpads is a private website run by a small legion of volunteers, 3 dogs, 12.5 cats and an army of small, super smart, bio-engineered mice with pointy hats and tutu's. Search Engine Friendly URLs by vBSEO 3.2.0 RC7
Archive Links
Archive Links
Page generated in 0.89079 seconds with 19 queries