![]() |
|
|
| Subject:
CSS and IFRAME
Category: Computers > Internet Asked by: petef-ga List Price: $15.00 |
Posted:
20 May 2002 18:41 PDT
Expires: 27 May 2002 18:41 PDT Question ID: 17178 |
How can I apply a css stylesheet to the contents of an iframe *without* direct access to the inlined document? |
|
| There is no answer at this time. |
| The following answer was rejected by the asker (they reposted the question). | |
| Subject:
Re: CSS and IFRAME
Answered By: skermit-ga on 20 May 2002 18:55 PDT |
|
If you have PHP on your webserver, you can write a PHP wrapper to put a CSS tag into the new temp-html document that you iframe. Let's say you're iframing <a href="<a href="http://www.tinkywink.com/index.html">http://www.tinkywink.com/index.html</a>"><a href="http://www.tinkywink.com/index.html">http://www.tinkywink.com/index.html</a></a> . Instead, point the iframe to tinkywink.php and in this file: tinkywink.php: &lt;HTML&gt; &lt;HEAD&gt; &lt;LINK REL=StyleSheet HREF=&quot;example_style.css&quot; TYPE=&quot;text/css&quot;&gt; &lt;?php include(&quot;<a href="<a href="http://tinkywink.com/index.html">http://tinkywink.com/index.html</a>"><a href="http://tinkywink.com/index.html">http://tinkywink.com/index.html</a></a>&quot;); ?&gt; &lt;/HTML&gt; It's that simple. Good luck! | |
| |
| |
Reason this answer was rejected by
petef-ga:
The answerer gallantly admitted defeat in response to my request for clarification (q.v.) |
| The following answer was rejected by the asker (they received a refund for the question). | |
| Subject:
Re: CSS and IFRAME
Answered By: samrolken-ga on 24 May 2002 21:58 PDT |
|
I have searched, and there isn't a way to do this on the client side. skermit had a good idea going about doing it server side, but not enough there to implement it well. I'm assuming that you're using a unix-type server environment. In that case, I would put a shell script in the cgi-bin directory that does these things: First, use lynx to fetch the file you're going for. use the --source arguement to make lynx just spit out the file to standard output. That way, you'll get the source of whatever you need, even if it's a directory listing. Then, on that output, you'd want to insert the stylesheet right into the document. The easiest way to do this would be to use sed. This below is what you're going for: lynx --source http://whatever/ | sed 's/&lt;head&gt;/&lt;head&gt;&lt;link rel=&quot;stylesheet&quot; type=&quot;text\/css&quot; href=&quot;stylesheet-url-here&quot;&gt;/i' The idea of using the sed to insert the stylesheed link came from Spatula. [ <a href="<a href="http://www.spatula.net/">http://www.spatula.net/</a>"><a href="http://www.spatula.net/">http://www.spatula.net/</a></a> ] -- Sam Kennedy | |
| |
Reason this answer was rejected by
petef-ga:
Another reasonable idea but it didn't quite hit the spot. -- petef |
|
| Subject:
Re: CSS and IFRAME
From: dgl-ga on 21 May 2002 08:14 PDT |
Although the question doesn't say it, if that was an external site, then it you are trusting that external site with the ability to execute any php on your system which generally isn't a good idea. I think if it is an external site then because of cross site javascript you can't use javascript to edit details of the iframe, but if it was a page on the same domain then it would be possible to apply a stylesheet via javascript. |
| Subject:
Re: CSS and IFRAME
From: petef-ga on 22 May 2002 17:57 PDT |
> Although the question doesn't say it, if that was an external site, > then it you are trusting that external site with the ability to > execute any php on your system which generally isn't a good idea. No you're not. The php is a local wrapper for the remote file. |
| Subject:
Re: CSS and IFRAME
From: dgl-ga on 25 May 2002 00:59 PDT |
No. In this case it's not a problem anyway, but using include() is a mistake a lot of people make, because include allows a url they presume it can be used to include pages. But the use for include is to "includes and evaluates the specified file. " (http://www.php.net/manual/en/function.include.php), so in that case it is a risk. |
| Subject:
Re: CSS and IFRAME
From: crosenblum-ga on 14 Jun 2002 14:29 PDT |
Can't you just modify the contents of the iframe? I have done that tons of times, to have an on the fly rotating banner.. It was very sweet... |
| Subject:
Re: CSS and IFRAME
From: zeroasterisk-ga on 23 Jul 2004 13:26 PDT |
I concur - simply use JS on the parent page to edit/update the
contents of the IFRAME with a link to a different stylesheet, or an
inline style block.
<html>
<body>
<script type="text/javascript">
function appendiframe(theIFRAME,theAPPEND)
{
parent.frames[theIFRAME].document.body.innerHTML+=(theAPPEND);
}
</script>
<DIV onclick="appendiframe('test','<STYLE>h1{color:red;}</STYLE><br><br>appended
content')" style="font-weight:bold;background-color:#bbbbbb;color:black;">
Test 1
</DIV>
<iframe name="test" ID="test" src="html1.html" frameborder="1"
style="width:90%;" align="center">this is not it.</iframe>
</body>
</html>
html1.html can be any page with h1 tags, to see the change made. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
| Search Google Answers for |
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |