Javascript link SEO - javascript

I have a page where in a photo and description link is there, i want replace the hard coded link with a javascript,which will add them,as i dont want the search engine to scroll the links.I dont wanna use "nofollow" attribute.How to code it in js.

Update: I may have misunderstood you - I thought you want to keep search engine visibility. Can you clarify which one you want? If you don't want the links and images to be indexed, I'd say nofollow is in fact your best friend. A JavaScript based solution is of course doable, but will lock out clients that don't have it enabled.
Original answer
The usual way would be to keep the link in a standard href attribute, and adding a JavaScript onclick event that does its thing using the href, and returns false so the "normal" link doesn't get triggered.
This leaves a search engine-readable link in place, and enables clients with JavaScript disabled to still somehow access the image.
This technique is also known as progressive enhancement.

I would be surprised is Google couldn't handle links created from Javascript. If you want to keep the linked pages unindexed, use nofollow on the link or noindex on the target page or add them to robots.txt.

Related

Get Value of a textbox which is not in current document using Javascript

I've list of slides, and in one of the slide, I have a text box with name attribute as "deals". In the next page I have a button. On clicking of that button, I want to capture the deals which were placed in the previous html. How can I capture it?
Using
document.getElementsByName("deals")[0].value
will not work, because we dont have a tag with the above name. How can I fetch it?
Any ideas would be greatly appreciated.
P.S : I don't have access to other JS of the project.
Though I may not have understood the question correctly (for example, I don't know how much JavaScript you may change), here are some thoughts:
Solve the problem of "don't have a tag with that name": If the slides are on the same page, then instead of removing a DOM element,
a hide() may be useful (as an implementation of changing slides).
The slides are on different page of the same window: Try utilising Cookie or LocalStorage, if you can't change the way how the slides work.
Bad Hack but should work: Setting window.name. This special "variable" will persist as long as you are in the same window (even after page changes, as long as the page doesn't re-write it). This is some kind of a hacky way to get values across different domains (avoiding Cross Site issues...). This should help if your slides are being imported into some other presentation sites with an <iframe>.
Hope the above helps!

Single Page MVC Navigation

I am building a single page scrolling MVC website that needs to be able to move to different sections of the page when a link is clicked, preferably without refreshing the page, just scrolling to said location on click event. My question is whether this would be some JavaScript or whether I can do so with just some regular and some C#.
As Alexei Darmin said in a comment try to use #id's in divs and refer to those id's in your links, that's the tipical way to do it and you shouldn't have any problem unless you load the content dinamically, in that case you should implement a method in your angular control that force the async load to, at least, that point and move the user to it.
For single Page application, Angular Js is more efficient and you can achieve the performance also. And also if you use this script, your app is like Web Api,you can control your resolutions for different devices.
Angular Js is best , so you can use in your app. hope it will useful to you. Thanks.
just refer its useful to you :
Link1
Link2

JavaScript accordion behavior when it won't expand - set an href?

I have a JavaScript accordion on this site that features within it, the primary functionality for the site. It is based off of this post.
When someone has JavaScript disabled or for whatever reason the panels aren't expanding, is there a way to set it so that clicking on them will act as a traditional hyperlink?
That way users can still be directed to content that they need and the site isn't "broken" for them.
You can use the noscript tag to provide content for those that have JS disabled. That should work no matter what plugin you're using.
Read more: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
So, basically, you can really go creative and build a separate menu for non-JS users.

Which is more fast in going from one page to other, a link or a button?

Recently I designed a page which has a navigation bar with four buttons. The user is directed to different page on clicking each different button. For the buttons I'm using the following code,
<button type="button" class="subheader-buttons" onclick="window.loation=document.location.href='PAGE 1'">Button 1</button>
I'am using the above code for all the four buttons. Now I'am wondering whether it will be advantageous to use links instead of buttons? Do links goes from one page to another faster than the buttons?
I believe it is much faster just linking, since what your doing is executing javascript which takes more than just linking it in an href!
But still this is a very big debate!
I take this info from uxmovement.com
When we look at the web, links outnumber buttons on most websites. The reason for this is because
links are easier to create
links are simple and sufficient
links don’t overshadow content
Buttons, however, are the opposite.
buttons take more time and effort to create
buttons can come in different sizes, colors and styles
buttons can sometimes overshadow content
You can get more info on this website:
http://getlevelten.com/blog/randall-knutson/design-decisions-buttons-vs-links-fight
You should use <a href=""> over window.location.href, for several good reasons.
Firstly If you have your javascript disabled, then none of the links would work.
Google Bot do not interpret javascript, and so they won't follow any of your links.
For more info: window.location.href vs clicking on an Anchor
Using a standard HTML link is the common way to do it. Although both methods will be roughly as fast.
Technically, because you're using JS with your button, your browser has to run the code before sending you to a different page so it may take a fraction of a second longer.
You could make a link a button without using JS:
<a href="your-page.html">
<button>Your Page</button>
</a>
It's the same. You can use <button></button> if you want.
However, use javascript to link to other page may take a sightly slow, u can check by using network
I think a link would be faster. In both, the web server will be going to the link specified by href. However, a link would just be that - a call to redirect. However, a button, as far as I am aware, sends much more data to the webserver, and also has many more things react to it - aka more overhead. Therefore, the link may be faster. However, it would only have a marginal effect really, unless you had a lot of traffic to your website, so I don't think it matter to much - you should probably just go with whatever you feel comfortable with.
I also just wanted to point out that I don't think using javascript to navigate to the page like that may be the best idea, regardless of whether you are using links or buttons. Serving webpages is a job for the webserver, and thus javascript calls may not be the best. Using the language that you are using for your web server (and if you are not, then I suggest you start using a back-end for your website), you should be able to respond easily to the button click / page redirect. The upside of this would be that it would also allow for any extra work to be done on the page as required.
The difference wouldn't be significant (or even noticeable by human). There are other concerns (most importantly accessibility) as to whether to use onclick or href.

Change the URL in partial post back

I am developing a shopping site where user can search products using different criteria.
On checked_changed event of check box i want to change URL, but condition is that my page does not make full post back..
This answer will help you......
You need HTML5-able browser and some JavaScript. Here is the demo of HTML5 history feature.
GitHub implemented that feature for tree browsing. And there is screencast in railscast.com.
Original answer is :
change url without making page postback -- mvc
Perhaps this is the solution http://www.asual.com/jquery/address/ - asual provides the functionality for easily changing addresses on the fly
What I can see there is the same functionality where we link an anchor tag to a div in the same page by appending #. You can see the the URL is changing by just appending the #!gender=men/page=1 to the end.
Also there is no checkbox. I saw that portion in firebug. Its just an image. But we can achieve it through checkbox as well on the onclick event but just appending the #[your params] to the URL.
Thanks,
Sayed.

Categories

Resources