How can I email or text a link that activates a jumplink to an anchor?
I want to show people my showreel by directing them to my website via link, but not make them have to scroll down to it.
Add an id attribute to any element on your page:
<div id="something"></div>
Then add a # to the url and the id value:
http://example.com/page.html#something
Related
I want to navigate a site using watir. I can't find nor focus on an element to click on it. It's the Next link on top right of this url:
Companies
How can I test that the link exists and can focus on it to click it?
The link HTML is:
<a id="view:_id1:_id258:pager6__Next__lnk" href="#" title="Go to next page:">Next</a>
The identifiable attributes seem to be the id (being careful of the auto-generated portions) or the title. The link could be located by either:
browser.link(title: 'Go to next page:') # using title
browser.link(id: /Next__lnk/) # using partial id
You can check if the link is available by checking if it is present:
browser.link(title: 'Go to next page:').present?
You can click with:
browser.link(title: 'Go to next page:').click
The best example I can find of this is the URL of a google images page with a particular image selected. The URL changes for each image that is selected.
In my case, I have a Notebooks model and a nested Notes model. In the view showing all the notes, when the user clicks a note he/she is taken to the Note show view. Instead, I would like them to be shown a partial within the same view, but I'd like the URL to change to include info about the selected note.
How do I do this?
You can do this with replaceState() in javascript. When the user clicks on the notes you open the note any way you want (using an ajax call for instance) and then when it's open you use a callback to fire the replaceState() function that will replace the current url with whatever you want (I suppose the url of your note).
Then, when a user comes into you site with this precise url you can parse the url to show the note he requested (or let Rails default behaviour redirect him to your note show view).
Here is the documentation for replaceState(): https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#The_replaceState().C2.A0method
Here is a non working example of the corresponding view using jquery to illustrate my point:
= link_to "note", note_path(#note), id: 'x_link'
<script>
$('#x_link').click(function(e) {
e.preventDefault() //we do not let the event propagate
href = $(this).attr('href') //we get the href attribute of our note
$.get(href, function(data) {
show_partial(data) // write some method to display you partial
history.replaceState(null, null, href) //replace the current state
})
})
</script>
I noticed that with a URL of the format
facebook.com/username/timeline/2013/4
we move to the end of the specified month of the year.
Now I need to use an url to navigate a user in my timeline to a specific post (facebookID) in a way that he can still move up and down on timeline from this point of time (anchor).
Any clues?
On a Facebook page, each post's HTML element has its own unique HTML id.
You can make use of this fact to directly link to a post within a page on Facebook by identifying the post's id and using it as the fragment identifier in the URL.
To find a post's HTML element id, right click the particular post in your browser [I'm assuming Chrome], then click "inspect element". In the opened development environment, find an enclosing div of the inspected element which contains an id HTML attribute.
For example, a link to a particular post on Disney's March 2013 Facebook timeline is the following:
https://www.facebook.com/Disney/timeline/2013/02/#tl_unit_6154529015953642023
Is there a way to open a page and jump to a div ID when only part of the ID is known?
eg: http://wp-site.com/webpage.php#div-id-name-xxxx
where 'xxxx' is a set of numbers that are impossible to know until after the page has loaded.
I'm using a shortcode which generates a page element within a div where the beginning of the ID is standard (eg: tabs-bottom, contact-form, etc) followed by a unique number that is randomly generated each time the page loads.
I want to be able to link to the div on that page from another page, but with part of the ID being dynamic, I'm having trouble doing so. I thought passing a wildcard in the URL might be the way to go...
Any ideas?
ps: the pages are part of a Wordpress based site, if that helps.
On this site we've implemented Jquery Address to remember and load ajax content correctly
when using back/forward buttons in the browser.
The problem have arisen with links that has regular anchor points, that is:
<a href="product.php?prodid=5" name="product5" />a product link</a>
the purpose of this is of course to make brwoser scroll down to same position
you were before clicking the link and clicking back (this is a product listing page for the record).
Is there a way to exclude (or not include) certain links that jquery adress catches?
You could just exclude all of the links with a name attribute:
// Use this selector when initializing jQuery Address.
$('a:not([name])').address()