Getting URL with javascript - javascript-events

Because of an HTTP_REFERER issue I need to make a url pass from an https site to http.
I have this bit of javascript but it is not working.
Save this page as PDF
Can I also find out how I would append the current site using javascript their api url?
http://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=http://www.example.com
Any advice?

Need to block the initial anchor tag event.
Save this page as PDF

I would use either javascript or the href attribute, not both. I don't see how they would work well together.
You can use .preventDefault() as noted, but why put the href attribute there in the first place?
Is this what you're looking for? It should work on both http or https sites.
<a onclick="window.open('http://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=' + window.location.href, '_blank', 'location=yes,scrollbars=yes,status=yes');">Save as PDF</a>

Related

how to request if href have only https in selenium python

I'm try to finding broken links from website using selenium python. I almost done the script and executed its working good. but I'm facing issue while request the link to get status code. In my website anchor attribute have href="javascript:void(0) So I try to get href attribute value and request to get status-code(response code) but this javascript:void(0) is not a link. How Can i solve this?
anchor = driver.find_elements_by_tag_name("a")
for anchors in anchor:
if(requests.head(anchors.get_attribute('href')).status_code):
print(anchors.get_attribute('href'), "Valid link")
else:
print(anchors.get_attribute('href'), "Broken link")
javascript:void(0) is just a dummy placeholder. Your website may have JavaScript which actually handles clicks on that link. You'll have to investigate your website to see what it's actually designed to do on those clicks.

Why is my ajax content not being indexed by google

I have tried to set my site up ( http://www.diablo3values.com )according to the guidelines set out here : https://developers.google.com/webmasters/ajax-crawling/ However, it appears that Google has updated their indexes (because I see the revisions to the meta description tags) but the ajax content does not show up in the index.
I am trying to use the “Handle pages without hash fragments” option.
If you view either of the following:
http://www.diablo3values.com/?_escaped_fragment_=
http://www.diablo3values.com/about?_escaped_fragment_=
you will correctly see the HTML snap shot with my content. (those are the two pages I an most concerned about).
Any Ideas? Am I doing something wrong? How do you get google to correclty recognize the tag.
I'm typing this as an answer, since it got a little to long to be a comment.
First of all, your links seems to point to localhost:8080/about, and not /about, which probably is why google doesn't index it in the first place.
Second, here's my experience with pushstate urls and Google AJAX crawling:
My experience is that ajax crawling with pushstate urls is handled a little differently by google than with hashbang urls. Since google won't know that your url is a pushstate url (since it looks just like a regular url), you need to add <meta name="fragment" content="!"> to all your pages, not only the "root" page. And google doesn't seem to know that the pages are part of the same application, so it treats every page as a separate Ajax application. So the Google bot will never actually create a navigation structure inside _escaped_fragment_, like _escaped_fragment_=/about, as it would with a hashbang url (#!/about). Instead, it will request /about?_escaped_fragment_= (which you aparently already have set up). This goes for all your "deep links". Instead of /?_escaped_fragment_=/thelink, google will always request /thelink?_escaped_fragment_=.
But as said initially, the reason it doesn't work for you is probably because you have localhost:8080 urls in your _escaped_fragment_ generated html.
Googlebot only knows to crawl the escaped fragment if your urls conform to the hash bang standard. As users navigate your site, your urls need to be:
http://www.diablo3values.com/
http://www.diablo3values.com/#!contact
http://www.diablo3values.com/#!about
Googlebot actually needs to see these urls in the source code so that it can follow them. Then it knows to download the following urls:
http://www.diablo3values.com/?_escaped_fragment=contact
http://www.diablo3values.com/?_escaped_fragment=about
On your site you appear to be loading a new page on each click, and then loading the content of each page via AJAX too. This is not how I would expect an AJAX site to work. Usually the purpose of using AJAX is so that the user never has to load a whole new page. When the user clicks, the new content section is loaded and inserted into the page. You serve the navigation once and then you only serve escaped fragments of the content.

How does a website load only part of the page and still display full on URLs?

I am looking at the Gawker blogs (http://io9.com, http://lifehacker.com/) and I'm curious about how they are made.
When I click for on a link only the article part of the page reloads displaying a loading icon while it does.
But what I can't figure out is that links point to new URLs like io9.com/something/something and its not something like I see on ajax pages that they put a site.com/#something tag at the end of the url from javascript to mark the page after an ajax request.
Can I change the full blown URL from javascript or what is happening?
When it happens, the website is using the HTML5 History API. This API can change the url (via JavaScript) without changing the page.
See caniuse.com for browser support.
If you would like to implement it in yout website, backbonejs.org would be very useful.

Can be URLs of Ajax request be made without hashes?

I've configured mod_rewrite on the site, and all URLs look like site.com/smth/else
In profile section of the site I want to make ajax navigation, so URLs will be changed with hashes: site.com/profile#smth
Can I make these ajax URLs look like others (with slashes but not hashes) - is it possible?
It is not possible. The only possible way to change current url without reloading of the whole page - is to change its anchor part.

Prevent Audio Player from refreshing while page change

I'm creating a website in wordpress. I have a music player in it as its for a music artist. But I want the player to continue playing while the users move through the website. I dont want to use iframe as i want the url updated so the page can be bookmarked. Or is there any way to update the url and use iframe?
Somebody on the Wordpress forum asked the same question.
The best way (technically) to do this is indeed to use a CMS that supports surfing the site without page-refreshes, so using AJAX, as #jonny suggested.
jango.com seems to do this as does another site I can't remember.
If you load every page via AJAX, there's probably gonna be a drawback if you care about search-ranking .
any way to update the url and use iframe
maybe you need something like this
main.html
<script type="text/javascript">
function change_parent_url(url)
{
document.location=url;
}
</script>
player.html
after each click (how?): parent.change_parent_url (new_url_here);
I am not sure, but I've seen similar, iframe approach on weborama.ru:
look for window.location=, maybe it helps
If you change the URL fragment (the part after the #) on each page change, the URL in the address bar can always be bookmarked. If you do this with a frame (probably the easiest way), every page load would update the URL fragment of the parent document. If an incoming link has this fragment set you open the frame not with the homepage, but with the requested content page.

Resources