How do I pass URL parameter to an iFrame in Wordpress page?
-
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.
-
Answer:
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: <iframe src="http://external.website/page?country=sg¤cy=sgd" width="100%" height="300"></iframe> to <iframe src="http://external.website/page?country=sg¤cy=sgd" width="100%" height="300" name="iframeTarget" id="iframeTarget"></iframe> And now with jQuery or some JavaScript, you can change the iframe URL dynamically as you have a named target and and ID. Example. <a href="yoursite.php?andStrings=uptoyou&page=1" onclick="return loadIframe('iframeTarget', this.href)"> change link 1 </a> The jQuery function loadIframe(iframeName, url) { var $iframe = $('#' + iframeName); if ( $iframe.length ) { $iframe.attr('src',url); return false; } return true; }
wailer at Stack Overflow Visit the source
Related Q & A:
- How do I add custom attributes to javascript tags in Wordpress?Best solution by WordPress
- How can I change url name?Best solution by Yahoo! Answers
- How can I pass global variables into a function?Best solution by Stack Overflow
- How do i make a my yahoo but not a home page?Best solution by Yahoo! Answers
- How do I remove the Profile and Feeds sections from My Page?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.