Skip to content
    Moz logo Menu open Menu close
    • Products
      • Moz Pro
      • Moz Pro Home
      • Moz Local
      • Moz Local Home
      • STAT
      • Moz API
      • Moz API Home
      • Compare SEO Products
      • Moz Data
    • Free SEO Tools
      • Domain Analysis
      • Keyword Explorer
      • Link Explorer
      • Competitive Research
      • MozBar
      • More Free SEO Tools
    • Learn SEO
      • Beginner's Guide to SEO
      • SEO Learning Center
      • Moz Academy
      • SEO Q&A
      • Webinars, Whitepapers, & Guides
    • Blog
    • Why Moz
      • Agency Solutions
      • Enterprise Solutions
      • Small Business Solutions
      • Case Studies
      • The Moz Story
      • New Releases
    • Log in
    • Log out
    • Products
      • Moz Pro

        Your all-in-one suite of SEO essentials.

      • Moz Local

        Raise your local SEO visibility with complete local SEO management.

      • STAT

        SERP tracking and analytics for enterprise SEO experts.

      • Moz API

        Power your SEO with our index of over 44 trillion links.

      • Compare SEO Products

        See which Moz SEO solution best meets your business needs.

      • Moz Data

        Power your SEO strategy & AI models with custom data solutions.

      NEW Keyword Suggestions by Topic
      Moz Pro

      NEW Keyword Suggestions by Topic

      Learn more
    • Free SEO Tools
      • Domain Analysis

        Get top competitive SEO metrics like DA, top pages and more.

      • Keyword Explorer

        Find traffic-driving keywords with our 1.25 billion+ keyword index.

      • Link Explorer

        Explore over 40 trillion links for powerful backlink data.

      • Competitive Research

        Uncover valuable insights on your organic search competitors.

      • MozBar

        See top SEO metrics for free as you browse the web.

      • More Free SEO Tools

        Explore all the free SEO tools Moz has to offer.

      What is your Brand Authority?
      Moz

      What is your Brand Authority?

      Check yours now
    • Learn SEO
      • Beginner's Guide to SEO

        The #1 most popular introduction to SEO, trusted by millions.

      • SEO Learning Center

        Broaden your knowledge with SEO resources for all skill levels.

      • On-Demand Webinars

        Learn modern SEO best practices from industry experts.

      • How-To Guides

        Step-by-step guides to search success from the authority on SEO.

      • Moz Academy

        Upskill and get certified with on-demand courses & certifications.

      • SEO Q&A

        Insights & discussions from an SEO community of 500,000+.

      Unlock flexible pricing & new endpoints
      Moz API

      Unlock flexible pricing & new endpoints

      Find your plan
    • Blog
    • Why Moz
      • Small Business Solutions

        Uncover insights to make smarter marketing decisions in less time.

      • Agency Solutions

        Earn & keep valuable clients with unparalleled data & insights.

      • Enterprise Solutions

        Gain a competitive edge in the ever-changing world of search.

      • The Moz Story

        Moz was the first & remains the most trusted SEO company.

      • Case Studies

        Explore how Moz drives ROI with a proven track record of success.

      • New Releases

        Get the scoop on the latest and greatest from Moz.

      Surface actionable competitive intel
      New Feature

      Surface actionable competitive intel

      Learn More
    • Log in
      • Moz Pro
      • Moz Local
      • Moz Local Dashboard
      • Moz API
      • Moz API Dashboard
      • Moz Academy
    • Avatar
      • Moz Home
      • Notifications
      • Account & Billing
      • Manage Users
      • Community Profile
      • My Q&A
      • My Videos
      • Log Out

    The Moz Q&A Forum

    • Forum
    • Questions
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. Home
    2. SEO Tactics
    3. Technical SEO
    4. Would using javascript onclick functions to override href target be ok?

    Moz Q&A is closed.

    After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.

    Would using javascript onclick functions to override href target be ok?

    Technical SEO
    4
    9
    4242
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with question management privileges can see it.
    • isntworkdull
      isntworkdull last edited by

      Hi all,

      I am currently working on a new search facility for me ecommerce site... it has very quickly dawned on me that this new facility is far better than my standard product pages - from a user point of view - i.e lots of product attributes for customers to find what they need faster, ability to compare products etc... All in all just better. BUT NO SEO VALUE!!!

      i want to use this search facility instead of my category/product pages... however as they are search pages i have "robots noindex them" and dont think its wise to change that...

      I have spoken to the developers of this software and they suggested i could use some javascript in the navigation to change the onlclick function to take the user to the search equivelant of the page...

      They said this way my normal pages are the ones that are still indexed by google etc, but the user has the benefit of using the improved search pages...

      This sounds perfect, however it also sounds a little deceptive... and i know google has loads of rules about these kinds of things, the last thing i want is to get any kind of penalty or any negative reaction from an SEO point of view... I am only considering this as it will improve the user experience on my website...

      Can  any one advise if this is OK, or a "no no"...

      P.s for those wondering i use an "off the shelf" cart system and it would cost me an arm and a leg to have these features built into my actual category  / product pages.

      1 Reply Last reply Reply Quote 0
      • Everett
        Everett last edited by

        Hello James,

        Why do these pages have "no SEO value"? Is it because they are AJAX pages or because you have them noindexed? Or both?

        To answer your original question, using an on-click javascript event to send a user to a page other than the URL listed in the href tag is borderline. It goes beyond the risk level I would feel comfortable with on an eCommerce site, but a lot of affiliate sites do this. For instance, all of their links out to merchant sites may go through a directory called /outlink/ so the href tag might look like .../outlink/link1234 and appear to send the user to another page on their domain, when actually the user gets redirected to the merchant's (e.g. Amazon.com, Best Buy...) website. Sometimes the user is redirected from the /outlink/... URL and sometimes they never even get that far because the javascript sends them to the merchant's URL first.

        It is not cloaking unless you are specifically treating Google differently. If Google doesn't understand your site that is their problem. If you have code that essentially says "IF Google, THEN do this. ELSE do that" it is your problem because you are cloaking. Make sense? There is a very distinct line there.

        The bottom line is if you want to show users a certain page then you should be showing that page to Google as well. If the problem is the content on that page doesn't appear for Google (e.g. AJAX) then you should look into optimizing that type of content to the best of your ability. For example, look into the use of hashbangs (#!) as in:

        https://developers.google.com/webmasters/ajax-crawling/docs/getting-started

        1 Reply Last reply Reply Quote 0
        • Highland
          Highland @isntworkdull last edited by

          1. Google understands simple JS that is inline with your HTML. So Google understands that
          is a link to domain.com. You can obfuscate this further and Google might not understand it. I've not seen Google try to parse or execute JS but that doesn't mean they can't or won't in the future.

          2. I don't think Alan is right in that this is cloaking. Google doesn't understand the same thing users do. It's been an acceptable practice, for instance, to take content found in Flash and copy it to where Google can spider it. The spider pages are for Google but there's no way it would be indexed otherwise and the users can get the same exact content from the frontend experience. Cloaking is where you show two distinctly different pages with the intent of tricking the bots. As long as what Google is indexing is what end users will see, there's no problem.

          3. Google is very unlikely to spider AJAX. Many AJAX pages don't return any user readable content (most of mine return things like JSON, which is not for end user consumption) and , as such, are beyond the scope of indexation. Again, as in #2, you might want this content to be shown elsewhere if you want it indexed. https://developers.google.com/webmasters/ajax-crawling/

          1 Reply Last reply Reply Quote 1
          • isntworkdull
            isntworkdull last edited by

            ok, i am not keen on this approach, the developers have offered an alternative... but again, i'm not sure about it, they have said they can use ajax to force their search results / navigation over my current navigation / products on my category / product pages...

            this gets rid of having to use javascript to send to different url... but up above Alan mentions cloaking, which to my understanding is basically serving anything different for a search engine / person... and thats what this will do... it serves up a different navigation to people... and the products could be listed in a different order etc... search engines do not see the ajax...

            Is this any better? or just as negative?

            Highland 1 Reply Last reply Reply Quote 0
            • AlanMosley
              AlanMosley @isntworkdull last edited by

              Are they identical, you say the search equivalent, I just wouldn't treat search engines any different

              1 Reply Last reply Reply Quote 1
              • isntworkdull
                isntworkdull @AlanMosley last edited by

                even thou the content is identical?

                It is only the way that content can then be navigated that is different...

                AlanMosley 1 Reply Last reply Reply Quote 0
                • AlanMosley
                  AlanMosley @isntworkdull last edited by

                  Well then, yes I would be concerned, you are serving up different content to users, that is cloaking.

                  isntworkdull 1 Reply Last reply Reply Quote 0
                  • isntworkdull
                    isntworkdull @AlanMosley last edited by

                    Hi Alan,

                    i think i may have explained incorrectly - my search page does have the meta tag noindex,follow - it also has a canonical link back to the main search page (i.e search.html) so i do not think any of the search results will be indexed. So my concern is not duplicate content, this should not happen...

                    My concern is the fact i am using javascript to litterally divert customers from one page to another... its almost like the static pages are there only for the benefit of google... and thats concerning me...

                    AlanMosley 1 Reply Last reply Reply Quote 1
                    • AlanMosley
                      AlanMosley last edited by

                      Google can follow JavaScript links, unless you are very good at hiding them.

                      I would not worry too much about the duplicate content, don't expect the duplicates to rank, but your not likely to be penalized for them. you can use a canonical tag to point all search results back to the one page.

                      I would not no index any pages, any links pointed to a no-index page are pouring their link juice away. if you want to no index a page use the meta tag no-index,follow, this way the search engine will follow the links and flow back out to your site

                      read about page rank and how link juice flows

                      http://thatsit.com.au/seo/tutorials/a-simple-explanation-of-pagerank

                      isntworkdull 1 Reply Last reply Reply Quote 1
                      • 1 / 1
                      • First post
                        Last post

                      Got a burning SEO question?

                      Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.


                      Start my free trial


                      Browse Questions

                      Explore more categories

                      • Moz Tools

                        Chat with the community about the Moz tools.

                      • SEO Tactics

                        Discuss the SEO process with fellow marketers

                      • Community

                        Discuss industry events, jobs, and news!

                      • Digital Marketing

                        Chat about tactics outside of SEO

                      • Research & Trends

                        Dive into research and trends in the search industry.

                      • Support

                        Connect on product support and feature requests.

                      • See all categories

                      Related Questions

                      • MickEdwards

                        Correct use of schema for online store and physical stores

                        I have been getting conflicting advice on the best way to implement schema for the following scenario. There is a central e-commerce store that is registered to it's own unique address which is "head office". There are a few physical shops each of which has their own location and address. Each shop has its own landing page within /our-stores/. So each page on the website has the Organisation schema for the central 'organisation', something like: Then on each physical store landing page is something like the following as well as the Organisation schema: Is this correct? If it is should I extend LocalBusiness with store URL and sameAs for GMB listing and maybe Companies House registration? It's also been suggested that we should use LocalBusiness for the head office of the company, then Departmentwith the typeStore.  But i'm not sure on that?

                        Technical SEO | | MickEdwards
                        0
                      • Happy-SEO

                        Images, CSS and Javascript on subdomain or external website

                        Hi guy's, I came across webshops that put images, CSS and Javascript on different websites or subdomains. Does this boost SEO results? On our Wordpress webshop all the sourcescodes are placed after our own domainname: www.ourdomainname.com/wp-includes/js/jquery/jquery.js?ver=1.11.3'
                        www.ourdomainname.com/wp-content/uploads/2015/09/example.jpg Examples of other website: Website 1:
                        https://www.zalando.nl/heren-home/ Sourcecode:
                        https://secure-i3.ztat.net//camp/03/d5/1a0168ac81f2ffb010803d108221.jpg
                        https://secure-media.ztat.net/media/cms/adproduct/ad-product.min.css?_=1447764579000 Website 2:
                        https://www.bol.com/nl/index.html Sourcecode:
                        https://s.s-bol.com/nl/static/css/main/webselfservice.1358897755.css
                        //s.s-bol.com/nl/upload/images/logos/bol-logo-500500.jpg Website 3: 
                        http://www.wehkamp.nl/ Sourcecode:
                        https://static.wehkamp.nl/assets/styles/themes/wehkamp.color.min.css?v=f47bf1
                        http://assets.wehkamp.com/i/wehkamp/350-450-layer-SDD-wk51-v3.jpg

                        Technical SEO | | Happy-SEO
                        0
                      • patilhimanshu

                        Can OG titles be used as a substitute for Meta titles

                        We use og (open graph) titles in lieu of meta titles. Is there any downside to using just one. Should we be using both og and meta titles on our page. Appreciate any insight. Himanshu

                        Technical SEO | | patilhimanshu
                        0
                      • Dan-Lawrence

                        Custom hreflang tags in WP & using with Yoast

                        Hi My clients dev has added custom fields for adding hreflang tags to head of pages such as: "Rel Type", "The URL", and "Language Code" Am i right in thinking that until a different language/country version of the site is created these can remain empty or should they still be populated once added say with some sort of global reference or best left blank since will leave the head content global by default ? Also how important is it to add charset to the language code ? since seems optional ? Also this set up is on WP multi-site with Yoast and devs asked me the below: _One thing to note is that Yoast generates its own "canonical" tags - so if _
                        _you are going to use hreflang tags and canonical tags then you don't need to _
                        _add a canonical using the custom fields I have set up - Yoast has that _
                        sorted. _But if you are going down the route of NOT having any canonical tags - and _
                        _using a x-defult for the hreflang tags, I will need to try and suppress the _
                        _Yoast canonical tag so you can do this. Much depends on your approach and _
                        what you think is best. So how do i know if using canonicals or x-default, i take it best simplest to leverage Yoast and hence not add canonicals to custom fields ? Isnt x-default just for indicating language selectors/redirector not specific to 1 region? So long as havnt got those then good to proceed with Yoasts generated canonicals ? Cheers dan

                        Technical SEO | | Dan-Lawrence
                        0
                      • WebServiceConsulting.com

                        Can I use a 410'd page again at a later time?

                        I have old pages on my site that I want to 410 so they are totally removed, but later down the road if I want to utilize that URL again, can I just remove the 410 error code and put new content on that page and have it indexed again?

                        Technical SEO | | WebServiceConsulting.com
                        0
                      • mickey11

                        Using symbols in the html title of a webpage

                        If you a symbol in the title of a webpage will this dilute the keywords in the title
                        thus making it rank worse in search engines here is an example <title><br /> Black Shoe Polish<br /></title> versus <title><br /> ▶ Black Shoe Polish<br /></title> will the extra symbols count as words and thus the dilute the effectiveness of the Black Shoe Polish keyword. sort of making like 4 words instead 3. By the way, The reason to use a symbol is to make it stand on in the search engine results

                        Technical SEO | | mickey11
                        0
                      • gallantc

                        Starting a new product, should we use new domain or subdomain

                        I'm working with a company that has a high page rank on it's main domain and is looking to launch a new business / product offering.  They are evaluating either creating a subdomain or launching a brand new domain.  In either case, their current site will link contextually to the new site.  Is there one method that would be better for SEO than the other? The new business / product is related to the main offering, but may appeal to different / new customers.  The new business / product does need it's own homepage and will have a different conversion funnel than the existing business.

                        Technical SEO | | gallantc
                        0
                      • elephantseo

                        What tool do you use to check for URLs not indexed?

                        What is your favorite tool for getting a report of URLs that are not cached/indexed in Google & Bing for an entire site? Basically I want a list of URLs not cached in Google and a seperate list for Bing. Thanks, Mark

                        Technical SEO | | elephantseo
                        3

                      Get started with Moz Pro!

                      Unlock the power of advanced SEO tools and data-driven insights.

                      Start my free trial
                      Products
                      • Moz Pro
                      • Moz Local
                      • Moz API
                      • Moz Data
                      • STAT
                      • Product Updates
                      Moz Solutions
                      • SMB Solutions
                      • Agency Solutions
                      • Enterprise Solutions
                      Free SEO Tools
                      • Domain Authority Checker
                      • Link Explorer
                      • Keyword Explorer
                      • Competitive Research
                      • Brand Authority Checker
                      • MozBar Extension
                      • MozCast
                      Resources
                      • Blog
                      • SEO Learning Center
                      • Help Hub
                      • Beginner's Guide to SEO
                      • How-to Guides
                      • Moz Academy
                      • API Docs
                      About Moz
                      • About
                      • Team
                      • Careers
                      • Contact
                      Why Moz
                      • Case Studies
                      • Testimonials
                      Get Involved
                      • Become an Affiliate
                      • MozCon
                      • Webinars
                      • Practical Marketer Series
                      • MozPod
                      Connect with us

                      Contact the Help team

                      Join our newsletter
                      Moz logo
                      © 2021 - 2025 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                      • Accessibility
                      • Terms of Use
                      • Privacy

                      Looks like your connection to Moz was lost, please wait while we try to reconnect.