javascript - window.location.assign("link"), is not working -


here javascript code.

<script type="text/javascript">         function myfunc()         {             var filmname = document.getelementbyid("mysearch-text").value;             alert(filmname);             if(filmname == "parker")                  window.location.assign("http://www.google.com");             else                 alert("hello");          }            </script> 

if enter other string "hello" alert , if enter "parker" page "http://www.google.com" wont loaded. why happening?

edit: ok mentioned did remove "http://www.google.com" , added "http://stackoverflow.com" did not resolve problem. , cant load local html pages in same directory

if(filmname == "parker")                  window.location.assign("index.html"); // "./index.html" or ./index/html 

even not working. what's wrong

i have jquery libraries: jquery ui , jquery

question needs more of info think. here final edits

<!doctype html> <html lang="en">   <head>   <meta charset="utf-8" />   <!-- other style , js libraries, including jquery ui , regular jquery -->   <script>    $(document).ready(function() {     $(".youtube").fancybox();    }); // end ready </script>  <script>       $(document).ready(function(e) {      $('.tooltip').hide();     $('.trigger').mouseover(function() {     /* rest of it, not necessary here */    </script>      <script type="text/javascript">         function myfunc()         {             var filmname = document.getelementbyid("mysearch-text").value;             alert(filmname); // debugging             if(filmname == "parker")                  window.location.assign("index.html");             else                 alert("hello");          }            </script>  </head> <body>   <div id='mysearch-box'>     <form  id='mysearch-form'>       <input id='mysearch-text'  placeholder='' type='text'/><!-- input here guys -->       <button class = "none" id='mysearch-button' onclick = "myfunc()">search</button>      <!-- press button after entering "parker" -->     </form>   </div>  <!-- rest of html page --> </body> </html> 

i assume using form onsubmit event call myfunc, if have prevent default behavior return false; (for example)

html:

<form id="form">     <input type="text" id="mysearch-text">     <input type="submit" value="submit"> </form> 

js:

<script>     window.onload = function () {         document.getelementbyid("form").onsubmit = function () {             var filmname = document.getelementbyid("mysearch-text").value;             alert(filmname);             if (filmname == "parker") window.location.href = "http://www.w3fools.com";             else alert("hello");             return false; //prevent default behavior of submit event         }     }         </script>  

Comments