SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    url = parent.location.href;

    Code:
    	
    	url = parent.location.href;
    Why does that not work? adding that line gives me a javascript error of some sort in IE. I see nothing wrong with it. Yet if I take that out I don't get the error, if I put it in I get the error.

    Its in an IFRAME by the way.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some more info and/or a url would be helpful, but you can't access the .href property of location if the parent is on a separate domain. This could be the problem.
    ck :: bringing chris to the masses.

  3. #3
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay... any way around that separate domain thing?

    Ditto with:

    url = window.top.location.href;

    I switched that one line to the above and it works in one domain, but not another. The other one is trying to access across domains.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  4. #4
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See Burstmedia in their infinite "wisdom" only allows each publisher 1 default campaign per account, even if you run multiple sites.

    So I want to serve this javascript as a default that will detect what domain the parent (it's in an iframe) is and will serve the appropriate banner.

    I have this:

    Code:
    <script language = "javascript">
    	
    	var url = ""; 
    	
    	url = window.top.location.href;
    
    	url = url.toLowerCase();
    
    if (url.indexOf("literature") >= 0){
      document.write('<iframe id=sky src="http://www.online-literature.com/skyscraper2.php" width=160 height=600 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no>');
    
      document.write('</iframe>');    
    }
    
    if (url.indexOf("wilderness") >= 0){
      document.write('<iframe id=sky src="http://www.wilderness-survival.net/skyscraper2.php" width=160 height=600 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no>');
    
      document.write('</iframe>');    
    }
    </script>
    It works on my literature site, because the file itself is hosted on that site. However it doesn't work on my wilderness survival site - apparently because it's trying to get the parent info across domains.

    So, is there any work around?

    If there was a way I could test whether or not the parent information was accessable that would work as well.
    Last edited by aspen; Feb 19, 2002 at 16:45.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  5. #5
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't really know how this burstnet code is included but you could do something like this to pass the host into the iframe which contains the code:

    <html>
    <body>
    <script type="text/javascript">
    <!--
    document.writeln('<iframe src="http://www.youradserver.com/blah.html?' + location.host + '" width=160 height=600 ></iframe>');
    //-->
    </script>
    </body>
    </html>

    blah.html:
    <script type="text/javascript">
    <!--
    host = location.search.substring( 1 );
    //-->
    </script>
    ck :: bringing chris to the masses.

  6. #6
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to see if you can access the parent's info you could do this:

    if( typeof( parent.location.href ) != "unknown" ) {
    // can access it
    } else {
    // can't access it
    }
    ck :: bringing chris to the masses.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •