Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my code

HTML
<html>

<form name="form1" method="post" action="">
  <label for="urls"></label>
  <input type="submit" name="back" id="back" value="<"  önClick="myIframe.history.back()">
  <input type="submit" name="forward" id="forward" value=">" onClick="myIframe.history.forward()">
<input type="submit" name="Search" id="Search" value="Go" onClick="LoadPage()">
  <input type="text" name="urls" id="URL" value="http://">
</form>

<iframe src="http://www.google.com" width="500" height="400 frameborder="0" id="myIframe"></iframe>

 <script language="javascript"> 
   function LoadPage(){ 
     var objFrame=document.getElementById("myIframe"); 
     objFrame.src=document.getElementById("URL").value;
    }
  </script>

</html>


I can't seem to find the problem with this code, it works in dreamweaver, but once Its saved and I docuble click on it, to run it in my chrome broswer, it dosen't work??? can some one please explain?
Posted
Comments
bbirajdar 20-Jun-13 7:55am    
"it dosen't work" does not make any sense to me..
Sunasara Imdadhusen 20-Jun-13 9:05am    
What is error?
lewax00 20-Jun-13 13:00pm    
Not entirely relevant, but why are you making a browser that would most likely be run inside another browser? Seems like a strange design decision to me.
[no name] 20-Jun-13 20:04pm    
Just a fun education thing
[no name] 20-Jun-13 20:20pm    
Its going to be a chrome extension too XD

1 solution

Well you are missing both the <head> and <body> sections, which most browsers regard as essential for a 'well-formed' HTML document. You should also put your Javascript code in the <head> section, unless you have a specific reason for putting it further down on the page.

JavaScript
<html>
 
<head>

    <title>My Page</title>

    <script language="javascript">
        function LoadPage() {
         var objFrame = document.getElementById("myIframe");
         objFrame.src = document.getElementById("URL").value;
     }
    </script>

</head>

<body>

    <form name="form1" method="post" action="">
        <label for="urls"></label>
        <input type="submit" name="back" id="back" value="<" onClick="myIframe.history.back()">
        <input type="submit" name="forward" id="forward" value=">" onClick="myIframe.history.forward()">
        <input type="submit" name="Search" id="Search" value="Go" onClick="LoadPage()">
        <input type="text" name="urls" id="URL" value="http://">
    </form>
 
    <iframe src="http://www.google.com" width="500" height="400" frameborder="0" id="myIframe"></iframe>
 

</body>

</html>
 
Share this answer
 
v3
Comments
lewax00 20-Jun-13 12:58pm    
Best practice seems to be putting scripts at the end now, so the page can finish loading before the scripts are run.
Nick Fisher (Consultant) 21-Jun-13 4:09am    
Oh ok, thanks for that, I wasn't aware of that. I'm so used to having the Javascript in the header and just letting JQuery take care of it with the document.ready() function. :)
[no name] 20-Jun-13 20:18pm    
I tried it, and I also tried the script down the button, its not working :(
Nick Fisher (Consultant) 21-Jun-13 4:14am    
Hi, sorry there's not a lot more I can do at the moment, as the code looks fine to me. It certainly shows fine in my own browser, and I'm using IE8 - one of the easiest browsers to break with code. I would maybe try setting the 'DOCTYPE' tag at the top of the page to see if it forces Chrome to pick up the page properly. More info here:

http://www.htmlgoodies.com/primers/html/article.php/3701321/Using-the-DOCTYPE-Tag.htm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900