2

I am trying pass two variables at the end of every urls opened in an iframe with help of javascript.

In detail:
I have an html file home.html which may contains the javascript which am searching for and an iframe,which opens mysite.com.all the urls in mysite.com need to end with two variables which we have defined in javascript
eg:mysite.com/index.php?var1=a&var2=b
and I dont have access to server of mysite.com.
Any help will be appreciated

1
  • You are looking a way to parse the query string of the current URL from JavaScript. A web search will point you in the right direction. Commented Mar 4, 2013 at 7:01

1 Answer 1

2
<!DOCTYPE html>
<html>
<body>

Home body


<iframe id="myIframe">
  <p>Your browser does not support iframes.</p>
</iframe>

<script type="text/javascript">
    var par = '4720';
    document.getElementById('myIframe').src="http://php.net/cal.php?id="+par;
</script>

</body>
</html>
Sign up to request clarification or add additional context in comments.

3 Comments

Hi Tiziano picardi, Thanks a lot, your answer gives partial solution to me. My iframe url is dynamic but in script it is defined as static. Eg: I will define the iframe src as google.com and will do a google search and then will click on one of the url in the search results.All these urls need to be end with two variables as ? or # Thanks in advance
Do you need to append parameters to the links of the embedded page (in the iframe)? Note: you can't use Google in an iframe (X-Frame-Options)
If your need is to edit the content of the page in the iframe, you can't (security reasons). Domains, protocols and ports must match with your page

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.