Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #31081
| Path | csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Open all links in new window |
| Date | Fri, 05 Aug 2016 21:26:14 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 37 |
| Message-ID | <87eg63otcp.fsf@bsb.me.uk> (permalink) |
| References | <f6247ab2-1ae8-4753-81ed-f5b2fcdf7944@googlegroups.com> <59e0b44d-8ea8-431d-ae12-e7585917f23f@googlegroups.com> <8737mku9we.fsf@bsb.me.uk> <7956cde6-c641-485f-9144-e7ce529f0cd8@googlegroups.com> <87wpjwsj4w.fsf@bsb.me.uk> <56528385-a0f0-4b95-b138-830a6ad9beec@googlegroups.com> <87k2fvr1er.fsf@bsb.me.uk> <dcdbdbe6-80b7-48e1-a4d9-994adafede02@googlegroups.com> <878twbqpem.fsf@bsb.me.uk> <beb7a7da-49ff-48a5-88ac-64af5afcaaf6@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="27594"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nB1MoL6QXdDn1mZ9o6EpqorNaBrauB0o=" |
| Cancel-Lock | sha1:OsT34u4qstDnMhW//Hih4sV63xI= sha1:C63SAXJB+4ev3/nuRpd5NOnDLPg= |
| X-BSB-Auth | 1.4443c9779b2b1d3df304.20160805212614BST.87eg63otcp.fsf@bsb.me.uk |
| Xref | csiph.com comp.lang.javascript:31081 |
Show key headers only | View raw
Chandra <csakkoni@gmail.com> writes:
<snip>
> I'm using the below code to load 3rd party urls in a new tab.
>
> function uu() {
> var alllinks = document.links.length;
> var linkarray;
> var thelink;
>
> while (alllinks--) {
> linkarray = document.links[alllinks];
> thelink = linkarray.href;
>
> if (thelink.indexOf("http://www.google.co.in/") !== 0) {
> linkarray.target = "_blank";
> }
> }
> }
> window.onload = uu;
>
> Now, I want the sub-domains (micro-sites) also open in a new
> window. Like "http://books.google.co.in/",
> "https://groups.google.com/".
For every 'a' element whose href attribute starts with one of those two
example strings,
theLink.indexOf("http://www.google.co.in/")
will be !== 0 so the target attribute will be set to "_blank". That is
what you say you want. If it is not working, it is not working for some
reason I could not even guess at.
Have you read https://css-tricks.com/use-target_blank/ ?
--
Ben.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Open all links in new window csakkoni@gmail.com - 2016-07-27 01:44 -0700
Re: Open all links in new window JJ <jj4public@vfemail.net> - 2016-07-27 17:40 +0700
Re: Open all links in new window Flng Fck <nothanks@invalid.invalid> - 2016-07-27 15:21 +0200
Re: Open all links in new window csakkoni@gmail.com - 2016-07-27 23:33 -0700
Re: Open all links in new window "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-28 11:02 +0200
Re: Open all links in new window wmgill <webworker1950@gmail.com> - 2016-08-14 14:23 -0400
Re: Open all links in new window "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-14 23:31 +0200
Re: Open all links in new window wmgill <webworker1950@gmail.com> - 2016-08-14 17:43 -0400
Re: Open all links in new window Robert Baer <robertbaer@localnet.com> - 2016-08-18 16:11 -0800
Re: Open all links in new window "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-19 11:52 +0200
Re: Open all links in new window wmgill <webworker1950@gmail.com> - 2016-08-20 01:08 -0400
Re: Open all links in new window "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-20 09:15 +0200
Re: Open all links in new window wmgill <webworker1950@gmail.com> - 2016-08-20 12:09 -0400
Re: Open all links in new window "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-20 21:50 +0200
Re: Open all links in new window $Bill <news@todbe.com> - 2016-08-20 17:21 -0700
Re: Open all links in new window "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-08-20 19:48 -0700
Re: Open all links in new window "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-21 09:42 +0200
Re: Open all links in new window Andrew Poulos <ap_prog@hotmail.com> - 2016-08-21 19:29 +1000
Re: Open all links in new window "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-22 00:44 +0200
Re: Open all links in new window Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-08-22 21:58 +0100
Re: Open all links in new window $Bill <news@todbe.com> - 2016-08-22 21:52 -0700
Re: Open all links in new window "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-23 12:23 +0200
Re: Open all links in new window Scott Sauyet <scott@sauyet.com> - 2016-09-03 19:55 +0000
Re: Open all links in new window Chandramohan Akkoni <csakkoni@gmail.com> - 2016-08-03 22:28 -0700
Re: Open all links in new window Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-08-04 11:05 +0100
Re: Open all links in new window Chandramohan Akkoni <csakkoni@gmail.com> - 2016-08-04 03:46 -0700
Re: Open all links in new window Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-08-04 15:28 +0100
Re: Open all links in new window Chandramohan Akkoni <csakkoni@gmail.com> - 2016-08-05 01:34 -0700
Re: Open all links in new window Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-08-05 10:49 +0100
Re: Open all links in new window Chandramohan Akkoni <csakkoni@gmail.com> - 2016-08-05 02:56 -0700
Re: Open all links in new window Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-08-05 15:08 +0100
Re: Open all links in new window Chandra <csakkoni@gmail.com> - 2016-08-05 09:44 -0700
Re: Open all links in new window Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-08-05 21:26 +0100
csiph-web