how to inject javascript code in url to insert iframe in existing page
- by dotnetcoder
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);";