...

View Full Version : JavaScript Frames & QueryString



prakharbirla
05-30-2006, 04:40 AM
Hi,
I actually want to create a HTML page which has the capablity of reading a QueryString (x.html?querystring=test) and then using a hidden frame pass on the data to an ASP Script on another server.
For obtaining the QueryString i use the following:-


<script>
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
}
</script>

<script>
alert( getQueryVariable("QueryString") );
</script>


Now my problem is to create a dynamic frame(hidden) who's location chnges according to the QueryString like
http://someserver.com/sample.asp?QuerySting=TheValueGivenToTheHTMLFile

Thanks in Advance

Mr J
06-02-2006, 11:59 PM
If I understand correctly, with

http://someserver.com/sample.asp?iframepage.htm"

The following would go in sample.asp

<script type="text/javascript">

if (location.search.length > 0){
url = unescape(location.search.substring(1))
document.write('<iframe src="'+url+'" src="blank.htm" style="position:absolute;left:0px;top:-500px;visibility:hidden"></iframe>')
}

</script>

I have an example of usng an hidden iframe here

www.huntingground.freeserve.co.uk/webplus/iframes/iframe_hidden.htm



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum