0

Is there a way to go to an element without appending an id to the url, eg. to go to <h2 id="element1">, within a page we'd usually have to load the URL like so:

http://www.example.com/#element1

But is there a different way to do this? because this # is causing conflicts with jQuery cycle 2 I'm using.

I link from another page

user1937021
  • 10,151
  • 22
  • 81
  • 143

2 Answers2

1

You may looking for this

<body onLoad="window.scroll(0, 150)">

or like

$( document ).ready(function() {

 $('#element1').scrollHeight;

});
Piyush
  • 3,947
  • 9
  • 36
  • 69
0

You could use JavaScript to scroll the browser to the element (as per this answer), but you'd have to identify what you want to scroll to for that to work.

You say that using the fragment identifier conflicts with some other JavaScript code, which means you are more or less stuck using the query string. That however introduces caching problems.

I'd look at fixing your existing JavaScript so that you can use the fragment identifier in the URL for what it was designed for.

Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335