views:

78

answers:

3

Hi, my code is

<a href="#" target="_blank"  class="floatLeft" onclick="change('http://localhost/allwidgets/widgets.html');" >

function change(url)
{
    alert(url);
    document.getElementById("mainOuter").innerHTML=url;
}

Actually I want that url should go in innerHTML of mainOuter div and that page should display in that.

Please suggest....

Thanks

+1  A: 

It sounds like you may actually want an iframe:

<iframe id="someIframe"></iframe>

document.getElementById("someIframe").src = url;

If you want to actually modify a DIV's innerHTML, then you need to use a AJAX request to get the desired HTML, then use innerHTML. Libraries can make this easier.

Matthew Flaschen
not exactly u r right but i want that div should contain that user content as innerHTML
rajesh
+1  A: 
rahul
+1  A: 

You need an iframe to render the page, if that is what you intend.

place an iframe whereever you require an external document to be rendered. Update the iframes' src property with the url.

like

document.iframeId.src = url;

iframeId is the id of the iFrame component. If you don't already have the iframe in place then you can dynamically add a new iFrame as a child element of the 'mainOuter' div and set its src property.

Ashwin Prabhu