Transparent IFrame

Hi, i want my iframe like this:

<iframe width="100px" height="200px" allowtransparency="true" scrolling="no" frameborder="0" src="http://page.aspx"></iframe>

that's the basic code, don't worry about the src. Now inside that page.aspx there is some links like this with no color set, so it's blue.
then when i put this iframe above an black page the blue link does not look good. Any solution on the page.aspx side. i can't change the page that refer to the iframe. so is there an way to keep the colors of links of the page that is requesting the iframe?

i hope i express myself right.
LVL 1
rafaelrglAsked:
Who is Participating?
 
COBOLdinosaurCommented:
I assume the page in the iframe and the main page are not from the same domain in which case the answer is no.  If they are from the same domain it is possible, but we need to see code (the final HTMlL, not the asp).

Cd&
0
 
Tom BeckCommented:
Here's some javascript that copies all the stylesheets from the parent page to the iFrame page.

http://www.phpied.com/parents-styles-in-an-iframe/

Here's a jquery example.

http://stackoverflow.com/questions/4612374/iframe-inherit-from-parent
0
 
rafaelrglAuthor Commented:
Sorry for the dalay,

here is the thing about this problem, the iframe is on other domain. So lets say www.domain1.com is using my iframe that is on www.domain2.com. and he put an link to an js script on domain1 that create the iframe tag, so i have an js script on domain1.

now, i tryed both functions on the page you show me tommyboy, but none worked, i think because of different domains, but since i have an js script on domain1. any solution to this:

here is the functios you gave me, none worked for me.

<script type="text/javascript">
window.onload = function () {
  if(window.top && window.top.location.href != document.location.href) {
    var linkrels = window.top.document.getElementsByTagName('link');
    var small_head = document.getElementsByTagName('head').item(0);
    for (var i = 0, max = linkrels.length; i < max; i++) {
      if (linkrels[i].rel && linkrels[i].rel == 'stylesheet') {
        var thestyle = document.createElement('link');
        var attrib = linkrels[i].attributes;
        for (var j = 0, attribmax = attrib.length; j < attribmax; j++) {
          thestyle.setAttribute(attrib[j].nodeName, attrib[j].nodeValue);
        }
        small_head.appendChild(thestyle);
    }
    }
   }
}
</script>

Open in new window

<script type="text/javascript">
window.onload = function() {
    if (parent) {
        var oHead = document.getElementsByTagName("head")[0];
        var arrStyleSheets = parent.document.getElementsByTagName("style");
        for (var i = 0; i < arrStyleSheets.length; i++)
            oHead.appendChild(arrStyleSheets[i].cloneNode(true));
    }
}
</script>

Open in new window

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
COBOLdinosaurCommented:
You cannot script cross-domain, and that is definitive.  The browsers have specific security provisions that prevent it because of historical hack attacks that can be launched that way.  There is no way for the browser to determine if the scripting is an attack so all cross browser scripting is blocked.

The only solution is for the content of the iframe to be served from the same domain.


Cd&
0
 
Amandeep Singh BhullarCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
COBOLdinosaurCommented:
The answer I gave is definitive and widely document on EE, on the web, and in the standards specification.  It is commonly known by the majority of web developers.

Check Google

Cd&
0
 
COBOLdinosaurCommented:
in http:#a37339137

I indicate that it will not work cross domain, and everything that follows confirms that.  A well known reality in web development for modern browsers.

Cd&
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.