doniyor
doniyor

Reputation: 37934

changing the src of iframe not working

I am trying to create an iframe widget for some portion of my page. but if I navigate inside the iframe, the src of iframe is not changing. I need the actual URL of the page inside the iframe:

I tried:

var iframe_url = $('#iframe_tag').attr('src');

but i am always getting the initial src of iframe.

Upvotes: 0

Views: 489

Answers (1)

TheHacksaw
TheHacksaw

Reputation: 432

Unless the domain within the iFrame is the same as the page domain, you won't be able to do this as it violates XSS (Cross Site Scripting) rules.

If it is the same domain then you could use:

var iframe_url = $('#iframe_tag').contents().get(0).location.href;

Upvotes: 2

Related Questions