Virtual Helper


Any small thing looked at a greater depth have excellent structure or pattern behind them


My parallelogram law of forces

Philosophy of Mathematics

Is Mathematics really Hard?(specially for those who hate it).I have expressed my views regarding mathematics.How Mathematics is associated with all walks of human life.

learn more

Web technology

Everything in the world is connected.This is another nice article related to div tag.

learn more

Another webtechnology post

Funny illustration of webtechnology related concept.How web technology various branches associated with the human life

learn more

Free Educational Video

Treasure Resources

All open resources Educational resources under one shell for all subjects .Don't forgot to bookmark this.

learn more

small program (url) related to javascript



<html>

<head>

<script type="text/javascript">

window.location.href='http://www.google.com';

</script>

</head>

<body>

</body>

</html>



the above program is working but when I change the program using onclick event it didn't work.But the below code is perfectly valid when you just put alert box instead of window.location.href and you can check it by yourself.
<html>

<head>

<script type="text/javascript">

function hello()

{

window.location.href='http://www.google.com';

}

</script>

</head>

<body>

<form>

<input type="submit" id="intro" onclick="hello()" value="Reload the page" />

</form>

</body>

</html>

then one of my friend named whosaidwhat figured it out it is due to type submit and so he advised to change it to button and i tried it .Yes it worked.
<html>

<head>

<script type="text/javascript">

function hello()

{

alert("welcome");

window.location.href='http://www.google.com';

}



</script>

</head>

<body>

<form>

<input type="button" id="intro" onclick="hello()" value="Reload the page" />

</form>

</body>

</html>

when I asked the reason whosaidwhat bro told as follows
"I cannot really give you detailed information on the inner workings of how web browsers handle javascript on submit buttons. I imagine that because it is a submit button it will be submitting the forms data to another page, and would not be expecting a URL redirect as it would break the forms submission. The browser is probably set up to ignore the redirect if the type of control that calls the javascript is of type 'submit'. Sorry I cant offer more detail than this."


Responses

0 Respones to "small program (url) related to javascript"

Post a Comment

 
Return to top of page Copyright © 2010 | Platinum Theme Converted into Blogger Template by HackTutors