Javascript produces weird behavior
Permalink
Hello,
I just wanted to use a simple alert function so that when people would click a picture it would say: "Oops, you first have to register to watch the video".
After clicking it, the message box pops up like it is supposed to.
But, when I clicked OK it would send me to my homepage for some reason. I just want to stay on the same page.
How can I figure out how to fix this?
I just wanted to use a simple alert function so that when people would click a picture it would say: "Oops, you first have to register to watch the video".
<form> <input type="image" src="video.gif" onclick="alert('Oops, you first have to register to watch the video')"> </form>
After clicking it, the message box pops up like it is supposed to.
But, when I clicked OK it would send me to my homepage for some reason. I just want to stay on the same page.
How can I figure out how to fix this?
I adjusted my original post. I don't want to go to my homepage after clicking OK. I just want to show the message box, nothing more.
<img src="video.gif" onclick="alert('Your alert here')" />
Just use that line without the form parts.
Not sure what your question is exactly. Do you want to redirect to a different page?
Please provide more information about your code, unless what you posted is literally what you are using.