Mobile app version of vmapp.org
Login or Join
Vandalay111

: How to do a JavaScript redirection to the same page without hurting my SEO? I did something that does that when people land on my page for the first time, they get a JavaScript redirection

@Vandalay111

Posted in: #Javascript #Php #Seo #WebCrawlers

I did something that does that when people land on my page for the first time, they get a JavaScript redirection to the same page, but with PHP $_GET URL queries, then this page redirect back to the page without these queries, so the server got the screen's size of the client during this process.

The thing is that this redirection is done in JavaScript client-side, so I wonder if it could hurt my website's SEO in some ways (continue reading).

Here are solutions that I think could be good, but I'm not sure about what to do and what will happen if I do that. I don’t really know how Google scan sites, so I may be wrong:


Should I put this JavaScript redirect at the bottom of my page's code, so Google will have the time to scan my entire page before being redirected?
Should I put this JavaScript code in the <head> of the page so that there will be no waiting before the redirect is done, so human clients will be satisfied to not have to wait some milliseconds more, but Google will scan the second page instead of the first, or will incompletely scan the first?
Should I detect with PHP whether or not I should echo this JavaScript code based on the type of the visitor (human or not). If this is what I should do, how to do it simply?


This is important, as this JavaScript code is on each page and is echoed in PHP each time someone (or a robot) visits the site for the first time.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Vandalay111

2 Comments

Sorted by latest first Latest Oldest Best

 

@Cofer257

Your solution here is very misguided for several reasons, mainly that the user's browser must make not one, but three separate requests for the same page. That's tripling your traffic and greatly slowing down the user. You are also passing information back and forth many times between PHP and JavaScript which you simply do not need to do.

If you are showing images in a "lightbox" style popup on the page then there is no need for any server-side interaction at all. JavaScript can detect the browser width and request a different image instead.

Perhaps you would be better off looking for a pre-built lightbox plugin. Just search for "JavaScript lightbox plugin" and you will find hundreds of different ones. Many of them include an explicit "showImage" function, so you can attach a click event handler to the link/thumbnail, and in that handler check the screen width and either open the image directly or call the lightbox plugin.

10% popularity Vote Up Vote Down


 

@Smith883

Google can parse JavaScript and may view this weird behavior as deceptive. I can't say for sure if this is the case but by allowing Google to go through two redirects it may also create duplicate content.

If you really need to get the screen width why don't you just use JavaScript to get it?

<script type="text/javascript">
document.write(screen.width+'x'+screen.height);
</script>


This is also probably the most user friendly way of dealing with this problem as the user will not have to spend time going through needless redirects.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme