Syam Pillai
Syam Pillai

Reputation: 5217

Get the url parameter in the iframe at the target page

I have created a website called https:www.somePage.com and I'm rendering this page inside another website using iframe. Since I'm using the same iframe in different websites, to track the website that using my https:www.somePage.com I'm adding a parameter called page in the iframe src. So the iframe will be like

<iframe src="https:www.somePage.com?page=company_name" width="100" height="250">

How can I access the parameter page in my website https:www.somePage.com.

Upvotes: 1

Views: 2679

Answers (2)

Shubham
Shubham

Reputation: 1793

In javascript using location.search you can get the parameters. But you've to split it and get the desired value.

Upvotes: 1

Ruslan Abuzant
Ruslan Abuzant

Reputation: 631

The webpage containing the iframe is considered the HTTP_REFERER in server terms, and the window.top.locarion.href in client terms. So based on your development environment, you can fetch that. In PHP that would be $ref = $_SERVER["HTTP_REFERRER"] and in JS that would be window.top.location.href, good luck.

Upvotes: 0

Related Questions