Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7057027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:56:14+00:00 2026-05-28T03:56:14+00:00

I am trying to render some javascript in an iframe. The Javascript works when

  • 0

I am trying to render some javascript in an iframe. The Javascript works when I open it as part my rails server, i.e. I open it as part of the /public directory.

However, it fails when I open it either as just a plain html file or as part of the iframe. My code looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head><script src="http://www.google.com/adsense/search/ads.js" type="text/javascript"></script><script src="http://www.google.com/uds/api/ads/3.0/7945945e138d6d2d6c753e6353976ff6/search.IN.js" type="text/javascript"></script>
  </head>

  <body>


  <div class = "test" id="afs_adblock_0" style="padding: 0px px; background-color: ; height: 600px; width: 600px;" onmouseover="out_pixel = '/rd/out_pixel?target_host_path=http%3A%2F%2Fadsense.google.com&amp;pvid=7192&amp;msid=5&amp;fpos=0&amp;bpos=0&amp;bid=afs_adblock_0&amp;twiz_val=0&amp;durl=&amp;rq=350&amp;feed_id=0&amp;ex=1326646029&amp;cs=dca4b10de177c97d609359425b227904';"></div>


  </body>


<script type="text/javascript" charset="utf-8">
var pageOptions = {
  'pubId' : 'pub-8639021338656306',
  'query' : 'college',
  'channel' : '5150635874'
};
var afs_adblock_0 = {
  'container' : 'afs_adblock_0',
  'minTop' : '1x',
  'fontFamily' : 'arial',
  'fontSizeTitle' : '14px',
  'fontSizeDescription' : '12px',
  'fontSizeDomainLink' : '12px',
  'colorTitleLink' : '#0067B1',
  'colorText' : 'blue',
  'colorDomainLink' : 'green',
  'colorBackground' : '#D5E9F2',
  'titleBold' : true,
  'verticalSpacing' : 6,
  'rightHandAttribution' : true,
  'colorAdSeparator' : 'white',
  'height' : '500px',
  'width' : '300px',
  'siteLinks' : true,
'adLoadedCallback' : function(containerName, adsLoaded) {if(!adsLoaded){document.getElementById(containerName).style.display = 'none';}; track_afs_results('7192', containerName, adsLoaded, '1092dd58f07de305cb14c3a2661fe150');}};
document.getElementById('afs_adblock_0').style.padding='0px 20px';document.getElementById('afs_adblock_0').style.background='#D5E9F2';new google.ads.search.Ads(pageOptions, afs_adblock_0);

    var out_pixel = '/rd/out_pixel'
    var isOverIFrame = false;
    function processMouseOut() {
        isOverIFrame = false;
        top.focus();
    }
    function processMouseOver() { isOverIFrame = true;}
    function processIFrameClick() {
        if(isOverIFrame) {
          var xmlHttp = null;
          xmlHttp = new XMLHttpRequest();
          xmlHttp.open('GET', out_pixel, false);
          xmlHttp.send(null);
        }
    }

    function init() {
        b = document.getElementsByTagName("body")[0];
        if(/MSIE/.test(navigator.userAgent)){
          b.onunload = function() { processIFrameClick() };
        }
        else{
          b.setAttribute('onunload', 'javascript: processIFrameClick()');
        }
        var element = document.getElementsByTagName("iframe");
        for (var i=0; i<element.length; i++) {
            element[i].onmouseover = processMouseOver;
            element[i].onmouseout = processMouseOut;
        }
    }
    setTimeout("init();",800);
    </script>
<script src="http://www.google.com/uds/api/ads/3.0/7945945e138d6d2d6c753e6353976ff6/search.IN.js" type="text/javascript"></script>

What is happening here, I am about to pull out my hair!! What could be the difference between opening a file in an iframe and opening it via the rails server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:56:14+00:00Added an answer on May 28, 2026 at 3:56 am

    This page uses AJAX, therefore it needs to communicate with a web server. That web server needs to be on the same domain as the page. This cannot happen when it is opened as a file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to come up with the best way to render some hierarchical
I am trying to render a model in Direct3D using DrawIndexedPrimitives . However, I
My experience with rails and Javascript is very limited. I am trying to pop
I've got a Rails 3.2.1 app that I'm trying to include some jquery in.
I'm trying to learn some javascript and have gotten stuck. Right now, I have
I'm trying to pass some data to javascript in my view. I only want
I'm trying to get along with Rails 3 and some Ajaxification of my app
I'm currently trying to wrap my head around some JavaScript. What I want is
I'm trying to use a javascript library in django that requires some attributes for
Im trying to do a little render framework, since I need some more control

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.