English 中文(简体)
div的Load page,上层
原标题:Load page in div, go to top of that div

我已:

<script language="javascript"> 
function arata(temp) { 
            var req = new XMLHttpRequest(); 
            req.open("GET", temp, false); 
            req.send(null); 
            var page = req.responseText; 
            document.getElementById("produs").innerHTML = page; 
                      } 
</script>

并且

<a href="#produs" onclick="arata( facturaies_vezi.php?nrfacties=<?=$row[nrfacties];?>#produs ); return true;"  id="<?=$nrcrt;?>">See details</a>

并且

<div id="produs"></div>

So, when the link is clicked, the page loads in to div.

How can I do to align the top of div to the top of the viewpoint? I mean... something like using an #anchor.

问题回答

Try:

document.getElementById( produs ).scrollIntoView();

详见本文:

https://developer.mozilla.org/en/DOM/element.scrollIntoView

如果你想用一个 anchor子来做,请在<条码>和>上加上一个名称=“produs”></a>,在<条码>c>上填写,如果你不使用<条码>,则该编码应当发挥作用。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签