Hi Sam
No, I don’t want a link to anywhere. I want to close the page. No links!
Hi Sam
No, I don’t want a link to anywhere. I want to close the page. No links!
Let’s see if I understand what you are saying…
You want a button on the web page that effectively clicks the close “X” on the current page’s tab (or by whatever mechanism the current page is closed) and that’s it. No expectations of “what’s next”?
How about tricking google by directing to the page with location.href = 'https://foo.bar'
? I’m really d’accord with @TechnoBear that opening a new window unsolicitedly is a bad idea. As for myself, I’d leave. :-/
Ditto… F-A-S-T.!
Ditto here too
I am sorry if I could not explain myself, but that is not AT ALL what I want to do.
Anyway, thank you all.
Same for me. Almost. I leave instantly.
Desperate attempts to force me to stay (or register, or signup for a newsletter, or follow, or like, etc.) produce the opposite result.
I like to at least think I have some free will and an ability to make my own decisions.
But, IIRC all of the problems and pitfalls of such an approach were brought up, what, two years ago now?
If all of the evidence hasn’t convinced by now, I doubt if it ever will. Chances are we will still be getting “help me do this the wrong and difficult way” topics for some time to come.
Anyway, Back on-topic,
As said, a link can be styled to look like a button.
As long as a page is opened by script, it can be closed by script.
<a href="" onclick="window.open('qim-close.html')" >open</a>
<a href="" onclick="window.close()" >close</a>
Could you tell me where I said or implied that?
The fact that you are not using a modal overlay or a simple link to a page.
I’m fairly sure I understand what you want to do; what I don’t understand is why you want to do it.
Your problem, as stated, is that you are linking to the same content from two different pages, and you don’t want Google to penalise you for duplicate content. (It’s most unlikely they would; they’d simply show one page in search results and not the other.)
Your chosen solution to this is to open the link in a new window/tab (I’m not entirely clear how this helps the Google issue), and you now want to use JS to create a button which will close that window/tab.
It has been explained to you that simple links to a single page are both the easiest solution and the recommended solution. It has further been explained that opening links in a new tab/window is considered bad practice for reasons of usability and accessibility. And while it may not have been mentioned in this topic, I’m pretty sure I’ve already pointed out to you that if you use JavaScript for basic functionality, you need to ensure your site still functions with it disabled.
Despite all that, your chosen solution is still to open and close a new tab/window using JavaScript, and you want help creating and styling a button to accomplish the “close”.
If that’s not an accurate summary, then I apologise; I have, indeed, misunderstood the issue and I would be grateful if you could explain it again.
If that is accurate, then I suggest you first read http://webaim.org/techniques/hypertext/hypertext_links#new_window, which explains techniques to make opening new tabs/windows more user-friendly. I suggest you also read up on accessible use of JavaScript: http://webaim.org/techniques/javascript/. Otherwise, you may be solving your own perceived problem at the risk of creating problems instead for your site users.
Hi TechnoBear
Thank you for returning to this issue
I am fully aware and grateful for the dangers as understood by other forum members, but quite honestly I don’t see how they relate to my question. I started the thread by asking for a bit of code; when prompted to explain what I wanted it for, I gave a very close hypothetical example, which is somewhat removed from my real intention. After all, I just wanted a bit of code.
Meanwhile, I have found the technical solution to the problem.
Thank you
Perhaps the actual, rather than hypothetical, example might have elicited a better response. As I’m sure you realise, the best way to accomplish something on a site may vary according to the exact situation.
If you’d posed a question asking how to style an HTML table for your navigation links, we’d have told you that you were using the wrong approach; HTML tables should not be used for layout. And we’d have suggested the correct way to achieve the desired result with HTML and CSS.
In the same way, the approach you were suggesting was not a good one for the hypothetical scenario you described, so members tried to explain why and provide more helpful suggestions. (You need to remember, too, that you will not be the only person reading this topic; somebody coming later with a similar question will also need to know about accepted best practices.)
Touché!
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.