How to pass parameter in wordpress url?

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&currency=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&currency=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&currency=sgd" width="100%" height="300"></iframe> to <iframe src="http://external.website/page?country=sg&currency=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

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

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.