#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    68
    Rep Power
    13

    javascript:void() -> error on page


    Hey

    I am using the javascript:void() trick for making popups, but when clicking on the link, the status at the bottom of the page writes "error on page". I there any way to fix this? Or is there another way than using this method?

    My code is:

    Code:
    <script>
    <!--
    function loadwindow(addy)
    {
    window.open(addy,"","width=700,height=450,status=0,scrollbars=1,resizable=1")
    }
    -->
    </script>
    
    
    
    <A href="javascript:void()" onClick="loadwindow('exemple.htm')">bleh</A>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Posts
    1,882
    Rep Power
    19
    Try using <a href="javascript:" ....

    otherwise
    <A href="java script:void()" onClick="loadwindow('exemple.htm'); return false">bleh</A>
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    where do people again and again get the space in the "javascript:" from?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Posts
    1,882
    Rep Power
    19
    vBulletin inserts it.
    Last edited by degsy; March 5th, 2002 at 01:45 PM.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    ah ja, why is it not in my post then?
    anyway, since the whole code is converted to text, why does it do this?
    if you should be right, this would be a big problem, since i told many people to leave it out and then it worked...

    test:
    <a href="javascript:void">test</a>
    Code:
    <a href="javascript:void">test</a>
    letīs see...
    [edit]
    wow, you are right!!! big time bug in vBulletin i think! itīs only inside html tags.

    poor newbies that cutīnīpaste stuff from these posts
    [/edit]

    [another edit]
    got my 500th post
    [/another edit]
    Last edited by M.Hirsch; March 5th, 2002 at 01:50 PM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    back to the problem: the code i see on most pages is either <a href="#" onclick...> or <a href="javascript:void(0)">...

    maybe this helps. both do nothing but you get an error on the second if you have js disabled on some browsers.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2001
    Posts
    765
    Rep Power
    13
    1) javascript&#58;void() is incorrect - although your problem may be elsewhere - void is an operator, and needs an operand:

    javascript&#58;void(0)

    The only purpose for this syntax is to cancel any default action for the link (loading the href, specifically). A better way:

    <A href="javascript&#58;void loadwindow('exemple.htm')">bleh</A>

    Even better:

    <A href="javascript&#58;;" onClick="loadwindow('exemple.htm');return false;">bleh</A>

    Probably the best:

    <A href="exemple.htm" target="_blank" onClick="loadwindow('exemple.htm');return false;">bleh</A>

    The last will open a new window even in non-JS enabled clients. If memory serves, Jonathon deserves the credit for this excellent tip.

    The splitting of the javascript: is a security feature; next time, type in javascript&amp;#58; to bypass it. This also works for posting escape sequences, HTML spaces (&amp;amp;nbsp;), etc.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    The splitting of the java script: is a security feature; next time, type in javascript&#58; to bypass it. This also works for posting escape sequences, HTML spaces (&amp;nbsp, etc.
    can you tell me where the "security" is in this?
    from your explanation, i better convert any char to &#... i can make a script to do this, no prob. but WHY???
    i still consider this a bug... it is only replaced inside a tag that starts with < and and ends with >. if you donīt use the ">", it will display correctly.......

IMN logo majestic logo threadwatch logo seochat tools logo