javascript in address bar

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    #1

    javascript in address bar

    Hmm, I know you can use javascript in the address bar to display alert
    messages and misc. stuff like that.
    But when I try and control some forms it loadsa a new page for the loaded
    example...

    eg.

    javascript: document.forms[1].elements[1].checked=true;

    would load a blank page with 'true' written on it, is there a way to make
    the checked box checked through this method?


  • Michael Winter

    #2
    Re: javascript in address bar

    On Thu, 06 May 2004 10:12:25 GMT, Steve <dont_spam@hotm ail.com> wrote:

    [snip]
    [color=blue]
    > javascript: document.forms[1].elements[1].checked=true;
    >
    > would load a blank page with 'true' written on it,[/color]

    This is because an assignment operation evaluates to the value that was
    assigned. In this case, "true". The JavaScript URI scheme takes the
    expression and writes it to the page.
    [color=blue]
    > is there a way to make the checked box checked through this method?[/color]

    Use the void operator to nullify the value:

    javascript:void (document.forms[1].elements[1].checked=true);

    The assignment is still evaluated, and the checkbox checked, but as no
    value results from the expression, the page is left intact.

    Mike

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    Working...