| | |
Dynamic Include
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Here is a question I've yet to find an answer to.
I have some javascript I'd like to be dynamically inserted into a page when its called. The set up is this.
I have an <iframe> in my site and the pages that get linked to externally to go into the iframe obviously dont change the size of the iframe without a little help. The idea behind it is this.
I can resize the <iframe> based on the page that is being framed providing I put a tiny chunk of code in it. Thats not possible if I dont own the pages so the <iframe> will just add scroll bars which is very unattractive.
I'd like to take this script below and have it inserted into every EXTERNAL page I frame dynamically. In fact even a link to a .js would work.
So for instance if I took my web site and put an iframe in it with Daniweb.com as the page, I'd like this code to somehow be an addendum or part of the final render of daniweb.com for instance.
Is this insane or what?
Jared
I have some javascript I'd like to be dynamically inserted into a page when its called. The set up is this.
I have an <iframe> in my site and the pages that get linked to externally to go into the iframe obviously dont change the size of the iframe without a little help. The idea behind it is this.
I can resize the <iframe> based on the page that is being framed providing I put a tiny chunk of code in it. Thats not possible if I dont own the pages so the <iframe> will just add scroll bars which is very unattractive.
I'd like to take this script below and have it inserted into every EXTERNAL page I frame dynamically. In fact even a link to a .js would work.
PHP Syntax (Toggle Plain Text)
<script type="text/javascript"> function goSetHeight() { if (parent == window) return; // no way to obtain id of iframe object doc loaded into? no parentNode or parentElement or ... else parent.setIframeHeight('ifrm'); } </script>
So for instance if I took my web site and put an iframe in it with Daniweb.com as the page, I'd like this code to somehow be an addendum or part of the final render of daniweb.com for instance.
Is this insane or what?
Jared
You could use curl or file() to get the page and then add your code before sending it to the iframe. Doesn't sound very ethical though if you don't own the page.
•
•
•
•
Originally Posted by DanceInstructor
You could use curl or file() to get the page and then add your code before sending it to the iframe. Doesn't sound very ethical though if you don't own the page.
Jared
Browser security will not allow you to run scripts against pages not from your own webserver, but Danceinstructor is right, you could do this server-side. It's more work, of course, but server-side is the way to accomplish your goal.
Check out PHP's curl support, or better yet, my class_http.php makes it very easy to grab remote pages server-side.
http://www.troywolf.com/articles/php/class_http/
Check out PHP's curl support, or better yet, my class_http.php makes it very easy to grab remote pages server-side.
http://www.troywolf.com/articles/php/class_http/
![]() |
Similar Threads
- get length of a dynamic array (C++)
- Declaration of dynamic pointer array puzzle. (C)
- Dynamic arrays inside a class? (C++)
- Help w/ dynamic list funtction definitions (C++)
- Dynamic memory allocation homework (C++)
Other Threads in the PHP Forum
- Previous Thread: Declaring functions
- Next Thread: Need some help with parsing an XML file
| Thread Tools | Search this Thread |
apache api array basic beginner binary broken cache cakephp checkbox class cms code computing confirm cron curl customizableitems database date delete display dynamic echo email error external file files filter folder form forms forum function functions gc_maxlifetime google headmethod host howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction memmory memory menu mlm multiple mysql navigation oop parsing paypal pdf php phpmysql problem query question radio random recursion remote script search select server sessions sms snippet source space sql syntax system table thesishelp trouble tutorial update upload url validator variable video web youtube





