Link to page coordinates

Is there a way to link to other page content using coordinates without using #anchors? For example, say that I want the link to go directly to content 1200 pixels down the page. How can i do this? Javascript, server-side magic, it all takes as long as it works for the average visitor.

+2


source to share


5 answers


Saving coordinates in a hash

eg. http://example.com/page#123



Then with javascript scroll the window

window.onload = function(){
  var pos = window.location.hash.substring(1); //get hash & remove #
  window.scroll(0,pos);
};

      

+1


source


You can develop a plugin or browser extension that will allow you to do this, for people who have installed it as a minimum. Otherwise, no.



0


source


If you have control over another site, you can write javascript that looks at the query string for a parameter (i.e.? Y = 1200) and scrolls the page to that position, but I'm assuming you don't have access to the other site ?

0


source


This can be done with UserJS (Greasemonkey):

http://stackoverflow.com/##scroll-y:1200

      

But users have to install the script earlier.

0


source


A similar browser origin policy will prevent you from scrolling a frame or iframe while displaying content from a different domain. The most reliable method is to have your server fetch the page and insert the scrolling code.

0


source







All Articles