...

View Full Version : saving source of a page to a variable



Christian271
08-12-2008, 07:21 AM
I was wondering if there was a way to save the source of a page (same domain) to a variable. Any ideas?

Philip M
08-12-2008, 07:47 AM
No, that cannot be done in Javascript - as already indicated.

It is possible in PHP -

http://us2.php.net/manual/en/function.file.php

rnd me
08-12-2008, 01:41 PM
No, that cannot be done in Javascript - as already indicated.

It is possible in PHP -

http://us2.php.net/manual/en/function.file.php

LOL, WTF!!!

as who/what has already (incorrectly) indicated?





function IO(U, V) {
//LA MOD String Version. A tiny ajax library. by, DanDavis
var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
X.open(V ? 'PUT' : 'GET', U, false);
X.setRequestHeader('Content-Type', 'text/html')
X.send(V ? V : '');
return X.responseText;}

function pageSource() {return IO(window.location.href);}

var myVariable = pageSource();
alert(myVariable);

does this code not work for anyone?

i tested it in ie6, ie7,ff2,ff3,op9,op9.5, safari3...

what can't do this ?

Christian271
08-12-2008, 07:26 PM
No, that cannot be done in Javascript - as already indicated.

It is possible in PHP -

http://us2.php.net/manual/en/function.file.php
It was indicated that it's not possible to save the source of another domain but now I'm asking you can do it in the same domain.

Christian271
08-12-2008, 07:26 PM
LOL, WTF!!!

as who/what has already (incorrectly) indicated?





function IO(U, V) {
//LA MOD String Version. A tiny ajax library. by, DanDavis
var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
X.open(V ? 'PUT' : 'GET', U, false);
X.setRequestHeader('Content-Type', 'text/html')
X.send(V ? V : '');
return X.responseText;}

function pageSource() {return IO(window.location.href);}

var myVariable = pageSource();
alert(myVariable);

does this code not work for anyone?

i tested it in ie6, ie7,ff2,ff3,op9,op9.5, safari3...

what can't do this ?
Thanks I'll try that!

Christian271
08-13-2008, 01:50 AM
It works, :thumbsup: but I'm using frames (not iframes) and it shows the source for the frame I have it in, can you edit it to show the source of the main page?

rnd me
08-13-2008, 03:32 AM
function IO(U, V) {
//LA MOD String Version. A tiny ajax library. by, DanDavis
var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
X.open(V ? 'PUT' : 'GET', U, false);
X.setRequestHeader('Content-Type', 'text/html')
X.send(V ? V : '');
return X.responseText;}

function pageSource() {return IO(window.location.href);}
function topSource() {return IO(top.location.href);}
function parentSource() {return IO(parent.location.href);}

var myVariable = topSource();
alert(myVariable);

var myVariable = parentSource();
alert(myVariable);







not sure of your setup, but one of these should cover you.


-



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum