How to execute a HREF with a JavaScript

S

Stefan Mueller

I'd like to call a JavaScript function which does something and loads at the
end a new page like
<a href = "info.html">Next Page</a>

How can I do the above HTML command with a JavaScript?
Stefan
 
R

Randy Webb

Stefan Mueller said the following on 11/2/2005 11:02 PM:
I'd like to call a JavaScript function which does something and loads at the
end a new page like
<a href = "info.html">Next Page</a>

function someFunction(newHREF){
/do stuff
document.location.href = newHREF
}

How can I do the above HTML command with a JavaScript?

Thats not an HTML "command", it is HTML syntax. But see above.
 
S

Stefan Mueller

Wow, thanks a lot for this fast reply.

However, I figured out that I didn't ask exactly what I need.
I'd like to press a button like
<input type = "button" name = "MyButton" value = "Next Page" onClick =
"MyFunction(document.MyForm)">
and now I'd like to load a new page at the end of the function 'MyFunction'
(but I don't want to use submit).

Stefan
 
R

Randy Webb

Stefan Mueller said the following on 11/3/2005 12:11 AM:
Wow, thanks a lot for this fast reply.

However, I figured out that I didn't ask exactly what I need.
I'd like to press a button like
<input type = "button" name = "MyButton" value = "Next Page" onClick =
"MyFunction(document.MyForm)">
and now I'd like to load a new page at the end of the function 'MyFunction'
(but I don't want to use submit).

You do it the same way, except you pass it a URL or hard code it in your
function.

onclick="myFunction('document.myForm')"

function myFunction(formRef){
//process formRef
document.location.href="someNewURLHere";
}

And remember your site will be broken doing it that way since it won't
work without JS.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top