Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    197
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to force anchors not to open new window?

    In the simple HTML below I use an anchor to refer to another location on the same page. It works fine on my pc and also when sending it by mail to other people. Only when someone with a mail.com email-address receives the mail and uses the anchor a new window opens in stead of referring just to another place in the same window. I tried to keep it in the same window by using codes like onclick="this.target='_self';" and onclick="self.location=this.href;return false" but in mail.com it does not seem to work. Does anyone know other ways to prevent a new window opening?

    This is the code I use:
    <html>
    <head>
    <title> How about this? </title>
    </head>

    <body>

    <a name="up"></a><br>

    Dit is suggestie 1 van Kicken en de script aan het eind. <br>
    Ook deze werkt niet<br><br>
    <a href="#anchor5" onclick="this.target='_self';">Press for Anchor5</a><br><br>
    <a href="#anchor6" onclick="self.location=this.href;return false">Press for Anchor6</a>



    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <br>
    <br>
    <a name="#anchor5"></a>Here is Anchor5<br>
    <a href="#up">Back-UP</a><br><br>
    <a name="#anchor6"></a>Here is Anchor6<br>
    <a href="#up">Back-UP</a>


    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>

    <script type="text/javascript">
    for (i in document.links){
    document.links[i].target='_self';
    }
    </script>

    </body>
    </html>

    Kippie

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Spain
    Posts
    420
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you asked the same question some time ago:

    How to avoid new window opens when using anchors?

    so I suppose that actually there is no solution for the problem
    Don't resist to assimilation. Billions of Borgs can't be wrong!

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    tried a simpler version

    have you tried doing this without all the javascript? I thought it was supposed to work like this:

    <a href="#here" target=_self>here</a>
    <pre>



    </pre>
    <a name="here">Here</a>

    there's also _blank, _top, and _parent. I don't know if this works for inner page links, but it's definitely supposed to work when linked to a different webpage.

    Actually, I'm willing to bet you tried this before resorting to the javscripting research, but I thought I'd throw this up for you to look at.
    If at first you don't succeed, spend more time online researching javascript!
    Beck


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •