-6

I want it to open a website within a particular <div> tag, just like in the following link: Responsive. What am I doing wrong?

<html>
<head>
  <script>
   function mobile320()
    {
     window.location.assign("http://www.idevtechnolabs.com")
    }
  </script>

<style type="text/css">
 body{
  margin: 0px auto;
  padding: 0px;
  background: #06855a;
  text-align: center;
 }

.browser1{
  display: inline-block;
  position: relative;
  width: 320px !important;
  height: 480px !important;
  background: #efefef;
 }
</style>
</head>

 <body>
   <input type="button" value="Load new document" onclick="mobile360()" />
   <div class="browser1"> </div>
 </body>
</html>
TylerH
  • 20,799
  • 66
  • 75
  • 101
iDev Technolab
  • 51
  • 1
  • 3
  • 9

3 Answers3

3

That's not a div, it's an iframe:

<iframe src="http://www.google.com"></iframe>
Emilio Rodriguez
  • 5,709
  • 4
  • 27
  • 32
2

put an iframe element in the div and navigate to the desired website,

or do an http get request and set the inner html of the desired div to the response string u get.

Banana
  • 7,424
  • 3
  • 22
  • 43
-1

Change your function to this:

function mobile320() {
    document.querySelector(".browser1").setAttribute("src", "http://www.idevtechnolabs.com");
}

...and your div to this...

<iframe class="browser1"></iframe>

Here's a working example.

Josh Harrison
  • 5,927
  • 1
  • 30
  • 44