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 6325441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:53:48+00:00 2026-05-24T16:53:48+00:00

I have tried in vain to find a solution for this issue, but to

  • 0

I have tried in vain to find a solution for this issue, but to no avail. Basically I am trying use JQuery to create a new dialog when a button on the page is clicked. The content of the dialog contains an IFrame referencing external (cross-domain) content. Inside the dialog I also want a “back” link (will change to a button later on) that acts similar to the browsers back button. Granted I could just get the user to use the normal back button, but this isn’t really all that intuitive hence I want the back button simply inside the dialog itself above the iframe.

The javascript for this is relatively simple using the “history” object. However, I want the ability to disable / remove this “back” link when the history count exceeds a certain level. The details of the disabling functionality are trivial enough, however I need to be able to access the load event of the iframe to determine when the content has finished loading so that the history.length value will be correct for the purposes of my test. However the load event seems to be fired too soon and the history value is not correct at the time the load event is fired. The history value appears to be correct when going “forwards” but after clicking my impromtu back button, the history value is no longer correct as it appears the load event is reporting a history value prior to the iframe having loaded the content.

Here is my current javascript:

<script language="javascript" type="text/javascript">
var baseHistory = 0;

$(function() {
  $("body").append('<div id="RedmapDialog" title="Dialog Title"></div>');
  $(".RedmapButton").bind('click', function(event) {
    baseHistory = history.length;
    var data='<a href = "javascript:history.go(-1)">Back to previous page</a>'
    data = data + '<iframe width="100%" height="100%" id="RMFrame"></iframe>'
    $("#RedmapDialog").html(data);
    $("#RedmapDialog").dialog("option", "title", 'Document: ');
    $("#RedmapDialog").dialog("open");
    $('#RMFrame').load(function() {
      alert("history.length=" + history.length);
    }).attr("src", "http://www.google.com/");
  });

  $("#RedmapDialog").dialog({  
    closeOnEscape: false,    
    height: 600,
    width: 800,
    autoOpen: false,    
    resizable: true,
    autoResize:true,
    modal: false           
  });  
});

</script>

and here is the calling html:

<div class="RedmapButton" style="cursor: pointer; cursor: hand;">
  <img src="/gui/images/bullseye.gif" width=26 height=26 alt="Redmap" title="Redmap">
</div>

Any thought’s as to why the load event is being called so soon after I select my back link? I understand that there are some cross-domain / same origin policy issues at play here, however I am not interested in the actual content of the iframe, simply the history.length value only.

Edit: Updated this post to include a suggestion by ShankarSangoli for setting the src of my iframe after its instantiation. However, I am still encountering the original issue whereby my “back” link still reports an incorrect history.length. Here is a jsfiddle link http://jsfiddle.net/fEgv9/1 that illustrates my issue. When run, click the “Redmap” image to display the iframe. Then click any link from google, and then hit my “Back to previous page” link, note that the history is not reporting correctly.

Thanks in advance.

  • 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-24T16:53:49+00:00Added an answer on May 24, 2026 at 4:53 pm

    In your code you are setting the source of the iframe when you added markup to RedmapDialog and after that load event handler is attached. Before it reaches this code the iframe must have already been loaded. Try to set the source of the iframe after you have set the iframe load event handler as below

    $(".RedmapButton").bind('click', function(event) {
        baseHistory = history.length;
        var data='<a href = "javascript:history.go(-1)">Back to previous page</a>'
        data = data + '<iframe src="javascript:void(0);" width="100%" height="100%" id="RMFrame"></iframe>'
        $("#RedmapDialog").html(data);
        $("#RedmapDialog").dialog("option", "title", 'Document: ');
        $("#RedmapDialog").dialog("open");
        $('#RMFrame').load(function() {
          alert("history.length=" + history.length);
        }).attr("src", "http://www.google.com/");
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have tried to find solutions for this and can't really come up with anything.
I have tried searching over the internet about this problem but not able to
I tried Matlab and the net to find an answer but in vain so
I tried searching this over the net but in vain. Is there a way
I have tried this: #define format(f, ...) \ int size = strlen(f) + (sizeof((int[]){__VA_ARGS__})/sizeof(int))
I have tried many permutations but they all don't seems to work well. Am
I have tried everything in the book and EVERYTHING I could find on how
I have tried to create a simple controller/model (based on the samples code of
I have tried all that i could to generate the R.java file but in
Possible Duplicate: Cannot connect to UserPC\SQLExpress I have been struggling to find a solution

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.