468,780 Members | 2,241 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,780 developers. It's quick & easy.

Detecting the Protocol of a Link


I'm making an Intranet site for someone who is not very familiar wit
making websites, thus I would like to make it as simple as possible fo
her when she needs to update it.

The intranet site uses frames - one menu frame that is always present
and one frame into which the content is loaded. The intranet sit
features many, many links to both internal and external pages - i
internal pages within the intranet and external pages on the interne
(http://)

What I would like to do is make it so that if a link is internal, th
content will load into the content frame and the menu frame will remai
at the side, but if the link is external, it will load the target int
the entire browser window. Using HTML, this would simply be a matter o
stating the href and then target="content_frame" for internal pages o
target="_top" for external pages.

But, like I said, I am making this site for someone who is not familia
with linking targets and even if I told her to define the targe
whenever she makes a link, she'd probably forget or get confused an
then wonder why external pages are loading with the intranet menu fram
still present or why intranet pages are loading with no menu at th
side!

While I have good experience with HTML, I am fairly new to JavaScript
which is why I am here asking for help.

I understand that Javascript can detect the protocol of a link,
believe you would use "link.protocol". In basic terms, what I woul
like to do is:

if link.protocol = "http://" then target="_top" els
target="content_frame"

But since I'm not familiar with the precise way of coding JavaScript,
would just like some help with transforming this into correc
JavaScript code so that it will work.

Thanks for taking the time to read this and for any help you can give

Unregistered
-----------------------------------------------------------------------
Posted via http://www.forum4designers.co
-----------------------------------------------------------------------
View this thread: http://www.forum4designers.com/message44568.htm

Jul 20 '05 #1
1 2861


Unregistered wrote:
I'm making an Intranet site for someone who is not very familiar with
making websites, thus I would like to make it as simple as possible for
her when she needs to update it.

The intranet site uses frames - one menu frame that is always present,
and one frame into which the content is loaded. The intranet site
features many, many links to both internal and external pages - ie
internal pages within the intranet and external pages on the internet
(http://)
But doesn't the intranet use the HTTP protocol too? Or are you loading
pages locally via file: urls?

I understand that Javascript can detect the protocol of a link, I
believe you would use "link.protocol". In basic terms, what I would
like to do is:

if link.protocol = "http://" then target="_top" else
target="content_frame"

But since I'm not familiar with the precise way of coding JavaScript, I
would just like some help with transforming this into correct
JavaScript code so that it will work.


If your intranet pages are loaded from the file system then
<a onclick="if (this.protocol == 'http:') {
this.target = '_top';
}
return true;"
for your links will do
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Jole | last post: by
5 posts views Thread by Fatih BOY | last post: by
1 post views Thread by JB | last post: by
15 posts views Thread by RobG | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.