Wordpress 3.2.1. I have a page which has an iframe embed of an external page. i.e. in WP page I have the following code
<iframe src="http://external.website/page" width="100%" height="300">
Is it possible to that I can dynamically set the external website source? via URL parameters? Suppose the above page was http://mysite.com/myiframe-page. If the page URL was http://mysite.com/myiframe-page?country=sg¤cy=sgd, I would like my iFrame SRC get the URL params. So iframe URL for the above page will be
<iframe src="http://external.website/page?country=sg¤cy=sgd" width="100%" height="300"></iframe>
Is this possible in wordpress? how? I am very new sorry.
Yes, iFrame can do this. However it is an old way of coding. I would recommend a Ajax request or some PHP include rather than iFrames.. sometimes in this case, it seems a quicker hack.
Simply change your code from this:
to
And now with jQuery or some JavaScript, you can change the iframe URL dynamically as you have a named target and and ID.
Example.
The jQuery