Expanding A Hidden Div By Referring With An Anchor From External Page
I have a script which hides (display:none) certain divs in the list on page load. Div contents represents description of a book, and the whole list is some sort of bibliography. E
Solution 1:
You can do something like this on the target page:
window.onload = function() {
var hash = window.location.hash; // would be "#div1" or somethingif(hash != "") {
var id = hash.substr(1); // get rid of #document.getElementById(id).style.display = 'block';
}
};
Essentially, you check on the page load whether the window's href has a hash attached to it. If it does, you find the <div>
and change the style display to block.
Solution 2:
Thank you! I figured out you can add this
location.href = '#' + id;
and also have the page scrolled to the position of the referred div.
Solution 3:
You can use the window.location.hash
to see the hash value.
From there you can getElementById(hashValue)
and show it.
Post a Comment for "Expanding A Hidden Div By Referring With An Anchor From External Page"