Source code...
Posted: Sun Sep 24, 2006 1:04 am
In Javascript, what property controls the window/frame's source code?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
document.body.innerHTML ?JellyFish wrote:The source code. Example, window.sourceCode = "Anyhtml I want";
Seriously, read up on DOM it's marvelous!JellyFish wrote:I wanna be able to change the complete source code of the window or frame. I want to be able to change the body tags and what's inside the head tags and even DTD tags.
Code: Select all
function include(path)
{
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = path;
document.getElementsByTagName('head').item(0).appendChild(newScript);
}
include('myscript.js');
Code: Select all
function onAjaxResponse()
{
if (ajaxObj.readyState == 4)
{
document.body.innerHTML = ajaxObj.responseText;
}
}
How cross browser is that include script you have there??? Excellent idea...I was working on something myself...although I was using a innerHTML not a DOM suggested approach. Turns out IE (I think it was) didn't parse the JS though.d11wtq wrote:Incuding a JavaScript document dynamically (like include() in PHP)JellyFish wrote:I wanna be able to change the complete source code of the window or frame. I want to be able to change the body tags and what's inside the head tags and even DTD tags.Code: Select all
function include(path) { var newScript = document.createElement('script'); newScript.type = 'text/javascript'; newScript.src = path; document.getElementsByTagName('head').item(0).appendChild(newScript); } include('myscript.js');
I imagine it will be much the same since both methods require a request and a response to be dealt with. The only difference as I see it is a readyState check and the initialization of the XMLHttpRequest object. Although I wonder if recent browsers take advantage of XMLHttpRequest transparently to do RPC type stuff.n00b Saibot wrote:I always use that method instead of going XMLHTTPRequest way... I suppose this is faster... anyone tested that?