SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    15
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Javascript:void(0); help!

    Hi,

    Im using the below script to close a Shadowbox window. Its working just fine. The issue is that it returns to the parent page. I need it to close and go to a new page like www.google.com. Is that possible using this script? What needs to be changed? Any suggestions?

    PHP Code:
    <a href=\"Javascript:void(0);\" onclick=\"parent.location.reload();window.parent.Shadowbox.close();\">Use this photo as my profile photo</a> 

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Location
    Singapore
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi GertK, I can't test this as I'm using my phone to reply but try this:

    Code:
    <a href=\"Javascript:void(0);\" onclick=\"window.parent.Shadowbox.close();location.href='http://google.com';\">Use this photo as my profile photo</a>

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,603
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Never use JavaScript in the href attribute unless the intention is for people to be able to right click and bookmark it.

    Best also to not use JavaScript in the HTML at all but to place it in a separate file.

    If the intention isn't to have the link go somewhere when JavaScript is disabled then you should use a <button> tag in place of the <a> tag.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Tags for this Thread

Bookmarks

Posting Permissions

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