how to inject javascript code in url to insert iframe in existing page

Posted by dotnetcoder on Stack Overflow See other posts from Stack Overflow or by dotnetcoder
Published on 2010-04-16T13:33:42Z Indexed on 2010/04/19 20:03 UTC
Read the original article Hit count: 191

Filed under:

I am able to get the following JS to create IFRAME and add it to the page.

The issue is if I create JS method on the page and ivoke it on a button click it works. But when I try to inject the same JS into the page url via setting the location.href it does not work the right way , rather it replaces the existing page with a new iframe.

Here is my code:

location.href = "javascript:ifrm = document.createElement('IFRAME');ifrm.style.width = 60+'px';ifrm.style.height = 40+'px';document.body.appendChild(ifrm);";

© Stack Overflow or respective owner

Related posts about JavaScript