HTML Link questions - html

When creating a link i need to find out if i can do the following:
blah
I want it so that if the user clicks on it, it will get the content as we described using ajax
however, i want the search engine to be able to follow the link so that we still get maximum indexing.
I'm pretty sure it should work but would like clarification

Set the href attribute of the link to the static page that you want the search engine to follow, then use the onclick event to do your javascript/ajax request for "human" users. As long as the onclick event returns false, the standard link won't be followed.
A good test of this would be turning javascript off and clicking the link - you should end up with what you want the search engine to see.
You don't need the "javascript:" string in the onclick attribute, it is only necessary if you are putting javascript in the href attribute. You should have something like:
blah

I asked similar question, where I got this answer from pekka:
The best way would be to degrade gracefully, e.g. by using a standard
<a id='mylink' href='xyz.html'>
link that points to the resource that is opened in the popup.
You would then add the JQuery code to the link, causing it to open in the pop-up.
That way, even users that do not have JavaScript turned on can access your popup.
Most Lightbox clones like Thickbox work that way.

Related

How to force load href that uses same URL but different hash params

Say that my navbar has these two URLs:
<a href='/action#?action_type=test'>test</a>
and
<a href='/action#?action_type=tset'>tset</a>
My problem is, say that you're in the 'test' page, if you click on the tset page it will just change the hash params and not force a load. The reason why I'm not using onclick listeners instead is because I want to let the user be able to ctrl + click on an element if they want it in a new tab. If I use onclick listeners that feature seems to go away. How should I proceed about this?
A hash param is actually called a fragment url.
Fragment urls aren't sent to the server (see other question), instead, they are supposed to be used to link to different parts of a page (using anchors). You shouldn't reload the page when you click on one, and browsers don't expect you too.
If you need to reload when you click a hash fragment, you're doing something wrong.
Instead, try using a query parameter instead, this will automatically reload from the server, and lets the browser know what you're doing.
<a href='/action?action_type=tset'>tset</a>
HTML requires you and the browser to agree on what you're doing. You could trick it with Javascript, but then you're losing support from the browser.
Either decide if you want to use Javascript, or decide to use query strings.

Using Google Chrome's console to perform searches

I work at a gym at the front desk. The website we use takes awhile to navigate using the GUI. This console in the Google Chrome browser seems pretty powerful. Can someone please direct me to some sort of tutorial or even answer this question yourself?
How would I use the Google Chrome console (inspect element > console) to perform searches using the website's search ability?
Thanks for your help!
You will need some basic understanding of javascript and DOM to do this.
If your site has a simple form for searching, you could use something like this.
document.getElementById('IdOfSearchField').value = 'test';
document.getElementById('IdOfSearchForm').submit();
What is does is that it fiends the searchfield and sets its value to "test" and then it submits the search form.
On this site (sorry for it being in Swedish, it was the one I was currently working on) you could use the following to search for 'test'.
document.getElementById('query').value = 'test'; document.getElementById('SpeedSearchForm').submit();
If your site has jQuery loaded you could simplify this a bit.
$('#query').val('test'); $('#SpeedSearchForm').submit();
Another way of doing it would be to navigate directly to the searchresult-page with the proper querystring (if that is supported by your website. In my sample case, it would look like this (because the search page is located at /search and just need the querystring query to work).
window.location = '/search?query=test';
But as ajp15243 noted in the comments on the question, it all depends on how your site is built. It's also a bit messy to type all that for every search.

HTML Form Tags, what is the actual default event or behavior?

This really isn't per say an exact problem. But I have been curious, and trying to look it up to find out. Just for my own curiosity's sake. So what is the default behavior of a browser in the event that you don't supply a method? or don't supply an action either? Yes, I know from a syntax point of view its not correct. However I notice a lot of people now with AJAX being the in thing, skimping out on the normal form tag attributes, this is what lead my curiosity. What if someone without JS enabled happens across a site with a form, that has no method and maybe no action?
Is there something standard browsers do? Like attempt to get/post on the page your currently on? Or some other event/behavior. I know when I click a submit button in one of these events that the page appears to be reloading. But is it post/get, other? Nothing at all?
I believe the W3 standard is to reload/request the same URL if no form action is supplied.
I can confirm this is what the latest Firefox 15 is doing.
According to the W3 standard, the default for method is the GET method. The action field is mandatory so if the browser does not know where to redirect the query, probably nothing will be send.

Difference between twitter share buttons

I simply want to add couple share button onto my page. And I see that people recommend different ways of doing it:
I see some articles using home?status:
<a href=”http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>” title=”Click to send this page to Twitter!” target=”_blank” rel=”nofollow”>Share on Twitter</a>
and some using share?url:
Tweet
What's the difference?
Your first example simply updates the status with the text you enter. The second example has a lot more functionality.
share?url supports class attributes for the anchor tag. In the anchor tag you can add things like data-related to suggest accounts the user will follow after they share the content or if you don't supply a url it will look for the current url the call is being generated from and share that. It has a lot more functionality vs the dumbed down home?status call.
find more here: https://dev.twitter.com/docs/tweet-button

Cloaking url but keeping sub-urls

I have a dot-tk (www.dot.tk) domain that redirects to a blog of mine.
But I have a problem. If a visitor of the blog who have entered through the tk-redirection, navigates to a specific post or even follows a link that leads elsewhere, then the URL-bar doesn't change to reflect the change. It always show the tk-address only. I want sub-urls to be visible so that the visitor can copy and send the url of that post to a friend or even bookmark the specific post.
This does works well if the reader has entered the blog from the normal url.
One "solution" to this would be to put this code in the blog:
<head>
<script type="text/javascript">if (top!=self) top.location.href=self.location.href;</script>
</head>
With this code the real url will always be seen, not the tk-url, even if the visitor have entered through the tk-url.
This works, but preferably I would like to show the tk-adress AND the sub-urls, if possible.
In other words...
Instead of http://myblog.blogspot.com it should be www.myblog.tk (this works)
And instead of http://myblog.blogspot.com/blogpost5 it should be www.myblog.tk/blogpost5 (This is what I need help with, if it's possible somehow)
I hope I've made myself clear and I hope there's a solution to it.
Thanks in advance!
I think you don't want to use this redirection scheme. Instead use Blogger's custom domain name functionality.