javascript in address bar

S

Steve

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?
 
M

Michael Winter

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

would load a blank page with 'true' written on it,

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.
is there a way to make the checked box checked through this method?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top