This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Microsoft Publisher > July 2006 > Opening hyperlinks in new or existing window





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Opening hyperlinks in new or existing window
tomZ

2006-07-10, 6:53 pm

G'day,
using Publisher 2000

I've read David Bartosik's "Hyperlinks that open a new browser window"
http://msmvps.com/blogs/dbartosik/a...1/13/81266.aspx
and reviewed postings in the n/g. I understand how to force links
to open in a new window.

However.......
I thought I saw/read ?somewhere? that there was a "global" setting
in MS Publisher that would set all links to open in new windows
instead of the default 'current window'. Naturally, I may have been
hallucinating (bad ice in my drinks ;), but if this sounds familiar
to any one else, I'd appreciate any response.

Thanks again to DavidB and DavidF for contributing so much of your
knowledge. Your, and all contributors', answers to posts are greatly
appreciated.

Cheers,
tomZ

--
If you spam my mailbox, you agree to accept any response I deem
appropriate.
Keep SIGNATURE AGREEMENT before replying.
"Any business model that relies on 'caveat emptor' is not ethical."
(aka Sony)
This posting may not be reversed engineered. My keyboard is proprietary.

DavidF

2006-07-10, 6:53 pm

G'day to you tomZ,

Thanks for your comments...

I am not sure if the following works or not. I haven't tested it, but ran
across it sometime in the past and saved it in my "sample scripts" folder.
If it doesn't work, perhaps it will lead you to an answer. If you do find a
solution, let us know...

-----------------

Open offsite links in new window:

---------------

<script language="JavaScript1.2">
<!--

//Open offsite links in new window option- By Jessica Hammer
//Heavily modified by Dynamic Drive
//Visit http://www.dynamicdrive.com for this script

//1)Enter domains to be EXCLUDED from opening in new window:
var excludedomains=["dynamicdrive.com", "javascriptkit.com"]

//2)Automatically open offsite links in new window? (1=yes, 0 will render a
checkbox for manual selection)
var auto=1

var excludedomains=excludedomains.join("|")
rexcludedomains=new RegExp(excludedomains, "i")

if (!auto)
document.write('<form name="targetmain"><input type="checkbox"
name="targetnew" checked onClick="dynamiclink()">Open off-site links in new
window</form>')

function dynamiclink(){

if (auto||(!auto&&document.targetmain.targetnew.checked)){
for (i=0; i<=(document.links.length-1); i++) {
if
(document.links[i].hostname.search(rexcludedomains)==-1&&document.links[i].href.indexOf("http:")!=-1)
document.links[i].target="_blank"
}
}
else
for (i=0; i<=(document.links.length-1); i++) {
if (document.links[i].hostname.indexOf(mydomain)==-1)
document.links[i].target=""
}
}

if (auto)
window.onload=dynamiclink

// -->
</script>

<p align="center"><font face="Arial" size="-2">Free DHTML scripts provided
by<br>
<a href="http://www.dynamicdrive.com">Dynamic Drive</a></font></p>

-----------------

DavidF

"tomZ" <WebMaster@127.0.0.1> wrote in message
news:e797ie0m1c@enews1.newsguy.com...
> G'day,
> using Publisher 2000
>
> I've read David Bartosik's "Hyperlinks that open a new browser window"
> http://msmvps.com/blogs/dbartosik/a...1/13/81266.aspx
> and reviewed postings in the n/g. I understand how to force links to open
> in a new window.
>
> However.......
> I thought I saw/read ?somewhere? that there was a "global" setting in MS
> Publisher that would set all links to open in new windows instead of the
> default 'current window'. Naturally, I may have been hallucinating (bad
> ice in my drinks ;), but if this sounds familiar to any one else, I'd
> appreciate any response.
>
> Thanks again to DavidB and DavidF for contributing so much of your
> knowledge. Your, and all contributors', answers to posts are greatly
> appreciated.
>
> Cheers,
> tomZ
>
> --
> If you spam my mailbox, you agree to accept any response I deem
> appropriate.
> Keep SIGNATURE AGREEMENT before replying.
> "Any business model that relies on 'caveat emptor' is not ethical." (aka
> Sony)
> This posting may not be reversed engineered. My keyboard is proprietary.
>



tomZ

2006-07-10, 6:53 pm

Thanks for the script David.
It's probably too far over my head, but I'll try it never the less.
I peruse the dynamicdrive website to see where to include and how to
use.

Cheers,
tomZ

DavidF wrote:

> G'day to you tomZ,
>
> Thanks for your comments...
>
> I am not sure if the following works or not. I haven't tested it, but ran
> across it sometime in the past and saved it in my "sample scripts" folder.
> If it doesn't work, perhaps it will lead you to an answer. If you do find a
> solution, let us know...
>
> -----------------
>
> Open offsite links in new window:
>
> ---------------
>
> <script language="JavaScript1.2">
> <!--
>
> //Open offsite links in new window option- By Jessica Hammer
> //Heavily modified by Dynamic Drive
> //Visit http://www.dynamicdrive.com for this script
>
> //1)Enter domains to be EXCLUDED from opening in new window:
> var excludedomains=["dynamicdrive.com", "javascriptkit.com"]
>
> //2)Automatically open offsite links in new window? (1=yes, 0 will render a
> checkbox for manual selection)
> var auto=1
>
> var excludedomains=excludedomains.join("|")
> rexcludedomains=new RegExp(excludedomains, "i")
>
> if (!auto)
> document.write('<form name="targetmain"><input type="checkbox"
> name="targetnew" checked onClick="dynamiclink()">Open off-site links in new
> window</form>')
>
> function dynamiclink(){
>
> if (auto||(!auto&&document.targetmain.targetnew.checked)){
> for (i=0; i<=(document.links.length-1); i++) {
> if
> (document.links[i].hostname.search(rexcludedomains)==-1&&document.links[i].href.indexOf("http:")!=-1)
> document.links[i].target="_blank"
> }
> }
> else
> for (i=0; i<=(document.links.length-1); i++) {
> if (document.links[i].hostname.indexOf(mydomain)==-1)
> document.links[i].target=""
> }
> }
>
> if (auto)
> window.onload=dynamiclink
>
> // -->
> </script>
>
> <p align="center"><font face="Arial" size="-2">Free DHTML scripts provided
> by<br>
> <a href="http://www.dynamicdrive.com">Dynamic Drive</a></font></p>
>
> -----------------
>
> DavidF
>
> "tomZ" <WebMaster@127.0.0.1> wrote in message
> news:e797ie0m1c@enews1.newsguy.com...
>
>



--
If you spam my mailbox, you agree to accept any response I deem
appropriate.
Keep SIGNATURE AGREEMENT before replying.
"Any business model that relies on 'caveat emptor' is not ethical."
(aka Sony)
This posting may not be reversed engineered. My keyboard is proprietary.

DavidF

2006-07-10, 6:53 pm

Tom,

Actually I had the same reaction, but after posting it, I decided to try
it...trial and terror, you know, and it does work. In fact, I may change my
Favorite Links page and use it instead of the method I currently use. It is
easier to use than you would think. I only played with the basic features
offered with the script, but perhaps that is all you need.

Just create a new, blank webpage. Create a text box with several lines of
sample text. Select a word on each line, and insert a hyperlink. Then copy
the code and create a "insert HTML code fragment box", (you can put it
anywhere on your page) and use Ctrl + V to paste the code into the fragment
box. Then do a web preview and click your links, and voila...they open in a
new window.

If you want to exclude a domain from opening in a new window, such as your
navbar links? (I didn't test this, but anticipate it might be a problem),
you will have to add them to the line:
var excludedomains=["dynamicdrive.com", "javascriptkit.com"]
Try adding one of the domain names in your sample links.

I also noticed that if you want you can delete this much of the script from
the bottom without affecting the way it works:

<p align="center"><font face="Arial" size="-2">Free DHTML scripts provided
by<br>
<a href="http://www.dynamicdrive.com">Dynamic Drive</a></font></p>

As you are giving credit to the author and dynamicdrive.com within the
source code, I personally don't feel I need to give them visual credit on
the page where I use the script, but you can decide that for yourself. If
you want to give them credit, then I would post the script at the very
bottom of your page. I may change my mind if I use the script, as I do
believe in giving credit where credit is due.

Good luck.

DavidF

"tomZ" <WebMaster@127.0.0.1> wrote in message
news:e7a0k801kep@enews4.newsguy.com...
> Thanks for the script David.
> It's probably too far over my head, but I'll try it never the less.
> I peruse the dynamicdrive website to see where to include and how to use.
>
> Cheers,
> tomZ
>
> DavidF wrote:
>
>
>
> --
> If you spam my mailbox, you agree to accept any response I deem
> appropriate.
> Keep SIGNATURE AGREEMENT before replying.
> "Any business model that relies on 'caveat emptor' is not ethical." (aka
> Sony)
> This posting may not be reversed engineered. My keyboard is proprietary.
>



Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews