Dynamic Include

Reply

Join Date: Feb 2005
Posts: 68
Reputation: php4ever is an unknown quantity at this point 
Solved Threads: 0
php4ever's Avatar
php4ever php4ever is offline Offline
Junior Poster in Training

Dynamic Include

 
0
  #1
Feb 24th, 2006
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.

  1. <script type="text/javascript">
  2. function goSetHeight() {
  3. if (parent == window) return;
  4. // no way to obtain id of iframe object doc loaded into? no parentNode or parentElement or ...
  5. else parent.setIframeHeight('ifrm');
  6. }
  7. </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
Dont hate me because I'm beautiful.....
Where I Work
Where I Rant :: Where Beauty Meets The Web
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: Dynamic Include

 
0
  #2
Feb 24th, 2006
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.
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 68
Reputation: php4ever is an unknown quantity at this point 
Solved Threads: 0
php4ever's Avatar
php4ever php4ever is offline Offline
Junior Poster in Training

Re: Dynamic Include

 
0
  #3
Feb 25th, 2006
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.
Ethics, yeah the alteration isn't one that should raise that question at all. Its just a way to get the page size so it can be framed correctly.

Jared
Dont hate me because I'm beautiful.....
Where I Work
Where I Rant :: Where Beauty Meets The Web
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 354
Reputation: Troy is an unknown quantity at this point 
Solved Threads: 5
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: Dynamic Include

 
0
  #4
Mar 4th, 2006
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/
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC