Jump to content

How to call a page to load in a div asynchronously and display at anchor point


MarkMan55

Recommended Posts

I'm using AJAX and making a call to load a file in a div.  The problem I'm having is making the file/document display at an anchor point.  Ex:  page1.html has four anchors and I want to use use AJAX to load the doc into a div and have it display at anchor point 3. When I make a call to load the page, nothing happens in IE6 and the page just loads at the top in Firefox.

 

Here is some example code:

 

function ajax()
     {
     var args = ajax.arguments;
     switch (args[0])
          {
          case "load":
          if (document.getElementById) {
               var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
               }
               if (x)
                    {
               x. />                          {
                    if (x.readyState == 4 && x.status == 200)
                              {
                              el = document.getElementById(args[2]);
                              el.innerHTML = x.responseText;
                         }
                         }
                    x.open("GET", args[1], true);
                    x.send(null);
                    }
               break;
          case "clear":
               el = document.getElementById(args[2]);
               el.innerHTML = "";
               break;
          }
     }

......

<span  return openNew(this.href);" href="http://www/" rel="nofollow" target="_blank">http://www.<anywhere>.com/dir/doc1.html#anchor1', 'displaydiv');">see document below</span>

<div id="displaydiv"></div> 
  


... and the code for the "doc1.html" file being loaded:

<a id="anchor1"></a> text......

<a id="anchor2"></a>text......

<a id="anchor3"></a>text......

<a id="anchor4"></a>text......

<a id="anchor5"></a>text...... 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.