...

View Full Version : Get Var from webpage source



WhiteCol
08-28-2011, 05:05 AM
Hi,

I would like to ask if there is anyway to get a variable from any webpage source using javascript.

Something like javascript: document.getelement?

Old Pedant
08-28-2011, 05:48 AM
Sure, document.NameOfVariable

But it only works if you have permission to access the page in question, and that generally means that the web page must come from the *SAME DOMAIN* as the page doing the "getting".

webdev1958
08-28-2011, 07:21 AM
I would like to ask if there is anyway to get a variable from any webpage source using javascript.


If you mean get a variable from a window's parent window then in the parent window


<script type="text/javascript">
var parVar = 'qwerty';
window.open('childPage.html');
</script>and in childPage.html

<script type="text/javascript">
alert(window.opener.parVar);
</script>or if you want to get a variable from a child window, then in the child page


<script type="text/javascript">
var childVar = 'zxcvb';
</script>and in the parent window


<script type="text/javascript">
var myWin = window.open('childPage.html');
alert(myWin.childVar);
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum