Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30981 > unrolled thread
| Started by | csakkoni@gmail.com |
|---|---|
| First post | 2016-07-27 01:44 -0700 |
| Last post | 2016-08-05 21:26 +0100 |
| Articles | 13 on this page of 33 — 14 participants |
Back to article view | Back to comp.lang.javascript
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
Page 2 of 2 — ← Prev page 1 [2]
| From | $Bill <news@todbe.com> |
|---|---|
| Date | 2016-08-22 21:52 -0700 |
| Message-ID | <npgkq1$mtd$1@dont-email.me> |
| In reply to | #31143 |
On 08-22-16 13:58, Dr J R Stockton wrote: > In comp.lang.javascript message <XnsA66C78487B00eejj99@194.109.6.166>, > Mon, 22 Aug 2016 00:44:20, Evertjan. <exxjxw.hannivoort@inter.nl.net> > posted: > >> Butlers are OT, even their holyday camps. > > I think you mean "Butlins" and "holiday" - > https://en.wikipedia.org/wiki/Butlins I'm pretty sure he meant butler when he said butler: > Perhaps he was really calling his family's butler, Reginald Jeeves, to assist?
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2016-08-23 12:23 +0200 |
| Message-ID | <XnsA66D7E0BE7262eejj99@194.109.6.166> |
| In reply to | #31143 |
Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> wrote on 22 Aug 2016 in comp.lang.javascript: >>Butlers are OT, even their holyday camps. > > I think you mean "Butlins" and "holiday" - > https://en.wikipedia.org/wiki/Butlins Yes. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Scott Sauyet <scott@sauyet.com> |
|---|---|
| Date | 2016-09-03 19:55 +0000 |
| Message-ID | <nqf9r2$h37$2@dont-email.me> |
| In reply to | #31105 |
wmgill wrote: > Evertjan. wrote: >> If my doctor prescribes me daily exercises, >> [he wouldn't dare, btw,] >> would it help my aching back if you 'do' those for me? > So that's what I'm doing wrong. :-) I'm catching up on several months worth of old USENET articles, and I just wanted to tell you, wmgill, in the face of the reception your comment got, that I found it quite funny. Thanks for the dose of humor. -- Scott
[toc] | [prev] | [next] | [standalone]
| From | Chandramohan Akkoni <csakkoni@gmail.com> |
|---|---|
| Date | 2016-08-03 22:28 -0700 |
| Message-ID | <59e0b44d-8ea8-431d-ae12-e7585917f23f@googlegroups.com> |
| In reply to | #30981 |
On Wednesday, July 27, 2016 at 2:15:10 PM UTC+5:30, Chandramohan Akkoni wrote:
> Dear Friends,
>
> I have a website www.xyzabc.com (dummy site mentioned) and on the tutorials web page I have 100+ urls. Few assets are linked to my site and few are 3rd party links. I need a script which excludes my links and all 3rd party links are opened in a new tab even if I do not add target="_blank" or onclick().The Code should not be applied manually on all links, it should be one simple code.
>
> Thanks in advance.
>
> Thanks,
> Chandramohan
I have the below code which work for small caps .pdf but does not work for .PDF and also I'm unable to check for .doc, .docx, etc.
----------------------------------------------------------------
var pdfAnchors = document.querySelectorAll("a[href$='.pdf']");
for(var i = 0; i < pdfAnchors.length; i++) {
pdfAnchors[i].target = pdfAnchors[i].target || "_blank";
}
----------------------------------------------------------------
Could you please check and get me the solution.
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2016-08-04 11:05 +0100 |
| Message-ID | <8737mku9we.fsf@bsb.me.uk> |
| In reply to | #31054 |
Chandramohan Akkoni <csakkoni@gmail.com> writes:
> On Wednesday, July 27, 2016 at 2:15:10 PM UTC+5:30, Chandramohan Akkoni wrote:
>> Dear Friends,
>>
>> I have a website www.xyzabc.com (dummy site mentioned) and on the
>> tutorials web page I have 100+ urls. Few assets are linked to my
>> site and few are 3rd party links. I need a script which excludes my
>> links and all 3rd party links are opened in a new tab even if I do
>> not add target="_blank" or onclick().The Code should not be applied
>> manually on all links, it should be one simple code.
>>
>> Thanks in advance.
>>
>> Thanks,
>> Chandramohan
>
> I have the below code which work for small caps .pdf but does not work for .PDF and also I'm unable to check for .doc, .docx, etc.
>
> ----------------------------------------------------------------
> var pdfAnchors = document.querySelectorAll("a[href$='.pdf']");
> for(var i = 0; i < pdfAnchors.length; i++) {
> pdfAnchors[i].target = pdfAnchors[i].target || "_blank";
> }
>
> ----------------------------------------------------------------
> Could you please check and get me the solution.
The most flexible solution is to go back to the regular expression
example (i.e. not using document.querySelectorAll) and change the match
to include all the links you care about. You can match them all in one
expression something like /^http|\.(pdf|doc|docx)$/i (untested).
But if you can rely on up-to-date browser support, you can use case
insensitive CSS attribute matching introduced in CSS4:
a[href$='.pdf' i]
which you'd combine with either having multiple (comma separated)
selectors in querySelectorAll, or making multiple calls to the function.
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | Chandramohan Akkoni <csakkoni@gmail.com> |
|---|---|
| Date | 2016-08-04 03:46 -0700 |
| Message-ID | <7956cde6-c641-485f-9144-e7ce529f0cd8@googlegroups.com> |
| In reply to | #31055 |
On Thursday, August 4, 2016 at 3:35:28 PM UTC+5:30, Ben Bacarisse wrote:
> Chandramohan Akkoni <csakkoni@gmail.com> writes:
>
> > On Wednesday, July 27, 2016 at 2:15:10 PM UTC+5:30, Chandramohan Akkoni wrote:
> >> Dear Friends,
> >>
> >> I have a website www.xyzabc.com (dummy site mentioned) and on the
> >> tutorials web page I have 100+ urls. Few assets are linked to my
> >> site and few are 3rd party links. I need a script which excludes my
> >> links and all 3rd party links are opened in a new tab even if I do
> >> not add target="_blank" or onclick().The Code should not be applied
> >> manually on all links, it should be one simple code.
> >>
> >> Thanks in advance.
> >>
> >> Thanks,
> >> Chandramohan
> >
> > I have the below code which work for small caps .pdf but does not work for .PDF and also I'm unable to check for .doc, .docx, etc.
> >
> > ----------------------------------------------------------------
> > var pdfAnchors = document.querySelectorAll("a[href$='.pdf']");
> > for(var i = 0; i < pdfAnchors.length; i++) {
> > pdfAnchors[i].target = pdfAnchors[i].target || "_blank";
> > }
> >
> > ----------------------------------------------------------------
> > Could you please check and get me the solution.
>
> The most flexible solution is to go back to the regular expression
> example (i.e. not using document.querySelectorAll) and change the match
> to include all the links you care about. You can match them all in one
> expression something like /^http|\.(pdf|doc|docx)$/i (untested).
>
> But if you can rely on up-to-date browser support, you can use case
> insensitive CSS attribute matching introduced in CSS4:
>
> a[href$='.pdf' i]
>
> which you'd combine with either having multiple (comma separated)
> selectors in querySelectorAll, or making multiple calls to the function.
>
> --
> Ben.
Dear Ben,
Thanks, this is working fine for small and big caps, but its unable to take the link that are appended with some ?src codes, which we use for analytics.
Can anything be do this "a[href$='.pdf' i]", I tried adding /g after i, and its not opening in a new window.
Thanks,
Chandramohan
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2016-08-04 15:28 +0100 |
| Message-ID | <87wpjwsj4w.fsf@bsb.me.uk> |
| In reply to | #31056 |
Chandramohan Akkoni <csakkoni@gmail.com> writes:
> On Thursday, August 4, 2016 at 3:35:28 PM UTC+5:30, Ben Bacarisse wrote:
>> Chandramohan Akkoni <csakkoni@gmail.com> writes:
>>
>> > On Wednesday, July 27, 2016 at 2:15:10 PM UTC+5:30, Chandramohan
>> > Akkoni wrote:
>> >> Dear Friends,
>> >>
>> >> I have a website www.xyzabc.com (dummy site mentioned) and on the
>> >> tutorials web page I have 100+ urls. Few assets are linked to my
>> >> site and few are 3rd party links. I need a script which excludes my
>> >> links and all 3rd party links are opened in a new tab even if I do
>> >> not add target="_blank" or onclick().The Code should not be applied
>> >> manually on all links, it should be one simple code.
>> >>
>> >> Thanks in advance.
>> >>
>> >> Thanks,
>> >> Chandramohan
>> >
>> > I have the below code which work for small caps .pdf but does not work for .PDF and also I'm unable to check for .doc, .docx, etc.
>> >
>> > ----------------------------------------------------------------
>> > var pdfAnchors = document.querySelectorAll("a[href$='.pdf']");
>> > for(var i = 0; i < pdfAnchors.length; i++) {
>> > pdfAnchors[i].target = pdfAnchors[i].target || "_blank";
>> > }
>> >
>> > ----------------------------------------------------------------
>> > Could you please check and get me the solution.
>>
>> The most flexible solution is to go back to the regular expression
>> example (i.e. not using document.querySelectorAll) and change the match
>> to include all the links you care about. You can match them all in one
>> expression something like /^http|\.(pdf|doc|docx)$/i (untested).
>>
>> But if you can rely on up-to-date browser support, you can use case
>> insensitive CSS attribute matching introduced in CSS4:
>>
>> a[href$='.pdf' i]
>>
>> which you'd combine with either having multiple (comma separated)
>> selectors in querySelectorAll, or making multiple calls to the function.
>
> Thanks, this is working fine for small and big caps, but its unable to
> take the link that are appended with some ?src codes, which we use for
> analytics.
It seems the first question was the tip of an iceberg -- no not just
external links but links and pdfs and docs. No, not just pdfs but in
any case. No, not just those but something else using ?src= as well.
Each refinement has the potential of making the current solution less
that idea. As some point another approach may well be better, so it
would help if you can back up and list, as best you can, the full set of
elements you want to find. Take care that there may also be elements
you *don't* want to include despite them sharing some pattern in common
with those you do.
> Can anything be do this "a[href$='.pdf' i]", I tried adding /g after
> i, and its not opening in a new window.
I am sure something can be done but "link that are appended with some
?src codes" is a bit vague. A wild guess suggests you might want to add
another selector, maybe like this:
"a[href$='.pdf' i], a[href~='src=']".
Have you read:
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started/Selectors
and
https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll
?
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | Chandramohan Akkoni <csakkoni@gmail.com> |
|---|---|
| Date | 2016-08-05 01:34 -0700 |
| Message-ID | <56528385-a0f0-4b95-b138-830a6ad9beec@googlegroups.com> |
| In reply to | #31058 |
On Thursday, August 4, 2016 at 7:58:53 PM UTC+5:30, Ben Bacarisse wrote:
> Chandramohan Akkoni <csakkoni@gmail.com> writes:
>
> > On Thursday, August 4, 2016 at 3:35:28 PM UTC+5:30, Ben Bacarisse wrote:
> >> Chandramohan Akkoni <csakkoni@gmail.com> writes:
> >>
> >> > On Wednesday, July 27, 2016 at 2:15:10 PM UTC+5:30, Chandramohan
> >> > Akkoni wrote:
> >> >> Dear Friends,
> >> >>
> >> >> I have a website www.xyzabc.com (dummy site mentioned) and on the
> >> >> tutorials web page I have 100+ urls. Few assets are linked to my
> >> >> site and few are 3rd party links. I need a script which excludes my
> >> >> links and all 3rd party links are opened in a new tab even if I do
> >> >> not add target="_blank" or onclick().The Code should not be applied
> >> >> manually on all links, it should be one simple code.
> >> >>
> >> >> Thanks in advance.
> >> >>
> >> >> Thanks,
> >> >> Chandramohan
> >> >
> >> > I have the below code which work for small caps .pdf but does not work for .PDF and also I'm unable to check for .doc, .docx, etc.
> >> >
> >> > ----------------------------------------------------------------
> >> > var pdfAnchors = document.querySelectorAll("a[href$='.pdf']");
> >> > for(var i = 0; i < pdfAnchors.length; i++) {
> >> > pdfAnchors[i].target = pdfAnchors[i].target || "_blank";
> >> > }
> >> >
> >> > ----------------------------------------------------------------
> >> > Could you please check and get me the solution.
> >>
> >> The most flexible solution is to go back to the regular expression
> >> example (i.e. not using document.querySelectorAll) and change the match
> >> to include all the links you care about. You can match them all in one
> >> expression something like /^http|\.(pdf|doc|docx)$/i (untested).
> >>
> >> But if you can rely on up-to-date browser support, you can use case
> >> insensitive CSS attribute matching introduced in CSS4:
> >>
> >> a[href$='.pdf' i]
> >>
> >> which you'd combine with either having multiple (comma separated)
> >> selectors in querySelectorAll, or making multiple calls to the function.
> >
> > Thanks, this is working fine for small and big caps, but its unable to
> > take the link that are appended with some ?src codes, which we use for
> > analytics.
>
> It seems the first question was the tip of an iceberg -- no not just
> external links but links and pdfs and docs. No, not just pdfs but in
> any case. No, not just those but something else using ?src= as well.
>
> Each refinement has the potential of making the current solution less
> that idea. As some point another approach may well be better, so it
> would help if you can back up and list, as best you can, the full set of
> elements you want to find. Take care that there may also be elements
> you *don't* want to include despite them sharing some pattern in common
> with those you do.
>
> > Can anything be do this "a[href$='.pdf' i]", I tried adding /g after
> > i, and its not opening in a new window.
>
> I am sure something can be done but "link that are appended with some
> ?src codes" is a bit vague. A wild guess suggests you might want to add
> another selector, maybe like this:
>
> "a[href$='.pdf' i], a[href~='src=']".
>
> Have you read:
>
> https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started/Selectors
>
> and
>
> https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll
>
> ?
> --
> Ben.
Dear Friends,
One last request.
Currently I have the below code which makes the external web page links open in a new window.
if (thelink.indexOf("http://www.google.co.in/" || "http://www.facebook.com/") !== 0){
linkarray.target = "_blank";
}
All the internal micro-sites are also opening on a new tab, which should happen. Example:
http://books.google.co.in/
http://developers.facebook.com/
Can these micro-sites also open in the same window. It should not be the repeat of above code keeping condition ===0 -> linkarray.target = "_self";
:)
Thanks,
Chandramohan
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2016-08-05 10:49 +0100 |
| Message-ID | <87k2fvr1er.fsf@bsb.me.uk> |
| In reply to | #31073 |
Chandramohan Akkoni <csakkoni@gmail.com> writes:
<snip>
> Currently I have the below code which makes the external web page
> links open in a new window.
>
> if (thelink.indexOf("http://www.google.co.in/" ||
> "http://www.facebook.com/") !== 0){
> linkarray.target = "_blank";
> }
Is that really what you have? Do you know what it does?
> All the internal micro-sites are also opening on a new tab, which
> should happen. Example:
> http://books.google.co.in/
> http://developers.facebook.com/
Did you miss out a "not"?
<snip>
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | Chandramohan Akkoni <csakkoni@gmail.com> |
|---|---|
| Date | 2016-08-05 02:56 -0700 |
| Message-ID | <dcdbdbe6-80b7-48e1-a4d9-994adafede02@googlegroups.com> |
| In reply to | #31074 |
On Friday, August 5, 2016 at 3:19:24 PM UTC+5:30, Ben Bacarisse wrote:
> Chandramohan Akkoni <csakkoni@gmail.com> writes:
> <snip>
> > Currently I have the below code which makes the external web page
> > links open in a new window.
> >
> > if (thelink.indexOf("http://www.google.co.in/" ||
> > "http://www.facebook.com/") !== 0){
> > linkarray.target = "_blank";
> > }
>
> Is that really what you have? Do you know what it does?
>
> > All the internal micro-sites are also opening on a new tab, which
> > should happen. Example:
> > http://books.google.co.in/
> > http://developers.facebook.com/
>
> Did you miss out a "not"?
>
> <snip>
> --
> Ben.
No no Ben, I have shared the dummy urls as examples. My need is to load the micro-sites in the same window. As with the current code, they are opening on a new tab.
Thanks,
Chandramohan
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2016-08-05 15:08 +0100 |
| Message-ID | <878twbqpem.fsf@bsb.me.uk> |
| In reply to | #31075 |
Chandramohan Akkoni <csakkoni@gmail.com> writes:
> On Friday, August 5, 2016 at 3:19:24 PM UTC+5:30, Ben Bacarisse wrote:
>> Chandramohan Akkoni <csakkoni@gmail.com> writes:
>> <snip>
>> > Currently I have the below code which makes the external web page
>> > links open in a new window.
>> >
>> > if (thelink.indexOf("http://www.google.co.in/" ||
>> > "http://www.facebook.com/") !== 0){
>> > linkarray.target = "_blank";
>> > }
>>
>> Is that really what you have? Do you know what it does?
>>
>> > All the internal micro-sites are also opening on a new tab, which
>> > should happen. Example:
>> > http://books.google.co.in/
>> > http://developers.facebook.com/
>>
>> Did you miss out a "not"?
>>
>> <snip>
>> --
>> Ben.
It's better to snip signatures.
> No no Ben, I have shared the dummy urls as examples. My need is to
> load the micro-sites in the same window. As with the current code,
> they are opening on a new tab.
Why don't you answer questions? You seem to expect help without helping
us help you. Do you know what the code you quoted does? I ask because,
as written, it is certainly wrong.
Another problem is that you are not showing us the code that does what
you say. Something is setting target = "_blank" for the sites you don't
want opened in a new window/tab. It may be that the best solution is to
fix that code rather than to add more.
<snip>
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | Chandra <csakkoni@gmail.com> |
|---|---|
| Date | 2016-08-05 09:44 -0700 |
| Message-ID | <beb7a7da-49ff-48a5-88ac-64af5afcaaf6@googlegroups.com> |
| In reply to | #31076 |
On Friday, August 5, 2016 at 7:38:40 PM UTC+5:30, Ben Bacarisse wrote:
> Chandramohan Akkoni <csakkoni@gmail.com> writes:
>
> > On Friday, August 5, 2016 at 3:19:24 PM UTC+5:30, Ben Bacarisse wrote:
> >> Chandramohan Akkoni <csakkoni@gmail.com> writes:
> >> <snip>
> >> > Currently I have the below code which makes the external web page
> >> > links open in a new window.
> >> >
> >> > if (thelink.indexOf("http://www.google.co.in/" ||
> >> > "http://www.facebook.com/") !== 0){
> >> > linkarray.target = "_blank";
> >> > }
> >>
> >> Is that really what you have? Do you know what it does?
> >>
> >> > All the internal micro-sites are also opening on a new tab, which
> >> > should happen. Example:
> >> > http://books.google.co.in/
> >> > http://developers.facebook.com/
> >>
> >> Did you miss out a "not"?
> >>
> >> <snip>
> >> --
> >> Ben.
>
> It's better to snip signatures.
>
> > No no Ben, I have shared the dummy urls as examples. My need is to
> > load the micro-sites in the same window. As with the current code,
> > they are opening on a new tab.
>
> Why don't you answer questions? You seem to expect help without helping
> us help you. Do you know what the code you quoted does? I ask because,
> as written, it is certainly wrong.
>
> Another problem is that you are not showing us the code that does what
> you say. Something is setting target = "_blank" for the sites you don't
> want opened in a new window/tab. It may be that the best solution is to
> fix that code rather than to add more.
>
> <snip>
> --
> Ben.
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/".
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2016-08-05 21:26 +0100 |
| Message-ID | <87eg63otcp.fsf@bsb.me.uk> |
| In reply to | #31077 |
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.
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.javascript
csiph-web