By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,070 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,070 IT Pros & Developers. It's quick & easy.

Internet Explorer Browser Extension: Switching from Live to Development and back again with a browser extension or BHO--how to create it?

P: n/a
Hello:

I would like to develop a browser extension, or whatever such a thing
is classified as, that would allow a user of IE6, and possibly IE7,
to
switch between a live and development page.

I'm sure the individuals reading this are familiar with what I'm
referring to; however, I'll provide an example.

I'm currently viewing a page, which is http://www.project.com/project-five.jsp,
and I would like to view the development version of that page, which
is http://project.dev.project.com/project -five.jsp--I would like to
switch back and forth
with one button, which of course would be "attached" to whatever
scripting language
accommodates such an action. I've had limited success with the "href"
and window.location
(or location.window) function in JS, but nothing that would allow me
to do the aforementioned.

I'm thinking that the code for this process would be executed by a
button
on the browser toolbar, which would be fed from the registry, which
is
probably the only part of this procedure I know how to perform.

I'm aware of Server Switcher, a browser add-on for FireFox, but I
would need to have this component for IE 6 and IE 7, and I would need
to develop this myself

I 'd like to know what tools I need for this type of project, and
what
type of programming I'm looking at; type of environment am I looking
at working in?

I've looked at some javascript and I've been given some code, but none
that I can seem to make work.

If this is a simple coding procedure that someone is familiar with
and
it could be provided here, it would be greatly appreciated.

If you believe that this message would be better suited posted to
another discussion group, please advise.
Thank you in advance for your time and attention.
---------------------------------------------------------------------------*-----
Daniel R. Young

Jun 12 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Danny said the following on 6/12/2007 11:12 AM:
Hello:

I would like to develop a browser extension, or whatever such a thing
is classified as, that would allow a user of IE6, and possibly IE7,
to switch between a live and development page.
I do that daily with IE7 and it is trivial. I open the development page
in on tab, the live page in another and switch between tabs. Why do I
need an add-on to allow me to do that? With IE6, there are already
add-ons that allow you to have tabbed browsing. Prior to the tabs, I
would simply open two browser windows and open two pages. No need for a
plugin/extension.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 12 '07 #2

P: n/a
On Jun 12, 12:23 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Danny said the following on 6/12/2007 11:12 AM:
Hello:
I would like to develop a browser extension, or whatever such a thing
is classified as, that would allow a user of IE6, and possibly IE7,
to switch between a live and development page.

I do that daily with IE7 and it is trivial. I open the development page
in on tab, the live page in another and switch between tabs. Why do I
need an add-on to allow me to do that? With IE6, there are already
add-ons that allow you to have tabbed browsing. Prior to the tabs, I
would simply open two browser windows and open two pages. No need for a
plugin/extension.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
If it were that simple, I wouldn't have posted such a question. An add-
on such as this is available in FireFox, which supports tabbed
browsing. This add-on would concatenate the dev. URL, keep the path
and file name, but replace the domain. Get it? If you don't
collaborate with end-users, I doubt you'd understand why there's a
need for such an add-on,

Thanks anyway.

Jun 12 '07 #3

P: n/a
Danny said the following on 6/12/2007 5:43 PM:
On Jun 12, 12:23 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>Danny said the following on 6/12/2007 11:12 AM:
>>Hello:
I would like to develop a browser extension, or whatever such a thing
is classified as, that would allow a user of IE6, and possibly IE7,
to switch between a live and development page.
I do that daily with IE7 and it is trivial. I open the development page
in on tab, the live page in another and switch between tabs. Why do I
need an add-on to allow me to do that? With IE6, there are already
add-ons that allow you to have tabbed browsing. Prior to the tabs, I
would simply open two browser windows and open two pages. No need for a
plugin/extension.
If it were that simple,
It *is* that simple and I even told you how.
I wouldn't have posted such a question.
Just because you ask a question doesn't mean the solution isn't simple.
An add-on such as this is available in FireFox,
Then someone wasted a lot of time on making something for Firefox that
is trivial to do without a plug-in/add on.
which supports tabbed browsing. This add-on would concatenate the dev. URL,
keep the path and file name, but replace the domain.
I can do that with a bookmark, add it to the toolbar. Why do I need an
addon?
Get it?
I got it the first time I answered you. You are the one trying to make
it more difficult than it is.
If you don't collaborate with end-users, I doubt you'd understand
why there's a need for such an add-on,
I "collaborate" with my end-users on a daily basis. Most times I
"collaborate" with them more than I wanted to.

x=document.location;
k = x.href.substring(8);
//change the 8 to pick up the parts you want to keep.
y = x.href.substring(0,8);
//change the 8 to pick up the live domain that you want to discard.
if(y="liveURLHere")
{x.href="devURLHere" + filePath}
else
{x.href="liveURLHere" + filePath}

Substitute the devURL and the liveURL, remove the comments, put it all
on one line, save it as a bookmarklet, add it to the IE toolbar.

Now, since you "Get it" and you seem to think I don't. Can you please
explain to me, and anybody else reading, why I need to install an addon
(to any browser) to allow me to do what the above bookmarklet will do?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 13 '07 #4

P: n/a
On Jun 13, 12:54 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Danny said the following on 6/12/2007 5:43 PM:
On Jun 12, 12:23 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Danny said the following on 6/12/2007 11:12 AM:
>Hello:
I would like to develop a browser extension, or whatever such a thing
is classified as, that would allow a user of IE6, and possibly IE7,
to switch between a live and development page.
I do that daily with IE7 and it is trivial. I open the development page
in on tab, the live page in another and switch between tabs. Why do I
need an add-on to allow me to do that? With IE6, there are already
add-ons that allow you to have tabbed browsing. Prior to the tabs, I
would simply open two browser windows and open two pages. No need for a
plugin/extension.
If it were that simple,

It *is* that simple and I even told you how.
I wouldn't have posted such a question.

Just because you ask a question doesn't mean the solution isn't simple.
An add-on such as this is available in FireFox,

Then someone wasted a lot of time on making something for Firefox that
is trivial to do without a plug-in/add on.
which supports tabbed browsing. This add-on would concatenate the dev. URL,
keep the path and file name, but replace the domain.

I can do that with a bookmark, add it to the toolbar. Why do I need an
addon?
Get it?

I got it the first time I answered you. You are the one trying to make
it more difficult than it is.
If you don't collaborate with end-users, I doubt you'd understand
why there's a need for such an add-on,

I "collaborate" with my end-users on a daily basis. Most times I
"collaborate" with them more than I wanted to.

x=document.location;
k = x.href.substring(8);
//change the 8 to pick up the parts you want to keep.
y = x.href.substring(0,8);
//change the 8 to pick up the live domain that you want to discard.
if(y="liveURLHere")
{x.href="devURLHere" + filePath}
else
{x.href="liveURLHere" + filePath}

Substitute the devURL and the liveURL, remove the comments, put it all
on one line, save it as a bookmarklet, add it to the IE toolbar.

Now, since you "Get it" and you seem to think I don't. Can you please
explain to me, and anybody else reading, why I need to install an addon
(to any browser) to allow me to do what the above bookmarklet will do?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

OK, I've used the wrong terminology and that's why you're viewing this
as superfluous-I at least that's why I've interpreted this as. Instead
of add-on, I should have said IE Toolbar button, but not a favorite.

I did as you suggested, with the code pasted above, and the script
host returned an error: "'window is undefined'."

It's possible that I didn't describe this requirement of the script. I
would need the script to understand that the path and filename will
not be the same in all instances. Sometimes you'd visit
http://www.live.com/file-path-name.jsp and want to switch to it's
respective development page, but other instances the file and path
name would be http://www.live.com/ff2-pp2-nn2.jsp, and I would need
the script to recognize the path and file name, capture it, (or
whatever function JS could provide in such a situation), and replace
the live domain (http://www.live.com) with the development domain
(http://live.dev.live.com).

Jun 13 '07 #5

P: n/a
Danny said the following on 6/13/2007 2:04 PM:
On Jun 13, 12:54 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>Danny said the following on 6/12/2007 5:43 PM:
>>On Jun 12, 12:23 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Danny said the following on 6/12/2007 11:12 AM:
Hello:
I would like to develop a browser extension, or whatever such a thing
is classified as, that would allow a user of IE6, and possibly IE7,
to switch between a live and development page.
I do that daily with IE7 and it is trivial. I open the development page
in on tab, the live page in another and switch between tabs. Why do I
need an add-on to allow me to do that? With IE6, there are already
add-ons that allow you to have tabbed browsing. Prior to the tabs, I
would simply open two browser windows and open two pages. No need for a
plugin/extension.
If it were that simple,
It *is* that simple and I even told you how.
>>I wouldn't have posted such a question.
Just because you ask a question doesn't mean the solution isn't simple.
>>An add-on such as this is available in FireFox,
Then someone wasted a lot of time on making something for Firefox that
is trivial to do without a plug-in/add on.
>>which supports tabbed browsing. This add-on would concatenate the dev. URL,
keep the path and file name, but replace the domain.
I can do that with a bookmark, add it to the toolbar. Why do I need an
addon?
>>Get it?
I got it the first time I answered you. You are the one trying to make
it more difficult than it is.
>>If you don't collaborate with end-users, I doubt you'd understand
why there's a need for such an add-on,
I "collaborate" with my end-users on a daily basis. Most times I
"collaborate" with them more than I wanted to.

x=document.location;
k = x.href.substring(8);
//change the 8 to pick up the parts you want to keep.
y = x.href.substring(0,8);
//change the 8 to pick up the live domain that you want to discard.
if(y="liveURLHere")
{x.href="devURLHere" + filePath}
else
{x.href="liveURLHere" + filePath}

Substitute the devURL and the liveURL, remove the comments, put it all
on one line, save it as a bookmarklet, add it to the IE toolbar.

Now, since you "Get it" and you seem to think I don't. Can you please
explain to me, and anybody else reading, why I need to install an addon
(to any browser) to allow me to do what the above bookmarklet will do?
OK, I've used the wrong terminology and that's why you're viewing this
as superfluous-I at least that's why I've interpreted this as. Instead
of add-on, I should have said IE Toolbar button, but not a favorite.
Why though? Why won't a favorite work if it can be coded to work?
I did as you suggested, with the code pasted above, and the script
host returned an error: "'window is undefined'."
That is an odd error as nothing in the script tried to access a "window".
It's possible that I didn't describe this requirement of the script. I
would need the script to understand that the path and filename will
not be the same in all instances.
I understood that part :-)
Sometimes you'd visit http://www.live.com/file-path-name.jsp and
want to switch to it's respective development page, but other
instances the file and path name would be http://www.live.com/ff2-pp2-nn2.jsp,
and I would need the script to recognize the path and file name,
capture it, (or whatever function JS could provide in such a
situation), and replace the live domain (http://www.live.com)
with the development domain (http://live.dev.live.com).
If all you want to change is the domain of the page, no sub folders,
then you simply read the document.domain property which gives you the
www.live.com (or live.dev.live.com part) of the URL. You check that to
see which it is - live or dev - and replace it with the other, then set
location.href of the current page. The snippet I posted before had a
flaw where it assumed (incorrectly) that the domain names would be the
same length when that isn't always true.

//set a variable to the location.href property
k=location.href;
//read the domain
m=document.domain;
//define a variable for each domain name
n="www.live.com";
p="live.dev.live.com";
//check the domain to see which it is and branch accordingly
if(document.domain == n){
//replace the domain name in k with the new domain name
k=k.replace(m,p);
}else{
//replace the domain name in k with the domain name of p
k=k.replace(m,n)
}
//k now equals a string that represents the new URL so
//set the location.href property to k
location.href = k;

When you strip out the comments, remove the linebreaks, and add the
javascript: protocol to it, you end up with this:

javascript:k=location.href;m=document.domain;n="ww w.live.com";p="live.dev.live.com";if(document.doma in==n){k=k.replace(m,p);}else{k=k.replace(m,n)}loc ation.href=k;

Save it as a bookmark.
Edit the n and p variables to match your respective domain names.

I don't have two live servers that I can tinker with right now to
thoroughly test it with but testing with variables instead of
location.href and document.domain I can't get it to fail in IE7. Try it
and if it still throws an error then let me know what the error was and
I will look into it some more. Whether you use a bookmark written in
javascript or any other language the process is the same.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 13 '07 #6

P: n/a
On Jun 13, 5:52 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Danny said the following on 6/13/2007 2:04 PM:


On Jun 13, 12:54 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Danny said the following on 6/12/2007 5:43 PM:
>On Jun 12, 12:23 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Danny said the following on 6/12/2007 11:12 AM:
Hello:
I would like to develop a browser extension, or whatever such a thing
is classified as, that would allow a user of IE6, and possibly IE7,
to switch between a live and development page.
I do that daily with IE7 and it is trivial. I open the development page
in on tab, the live page in another and switch between tabs. Why do I
need an add-on to allow me to do that? With IE6, there are already
add-ons that allow you to have tabbed browsing. Prior to the tabs, I
would simply open two browser windows and open two pages. No need for a
plugin/extension.
If it were that simple,
It *is* that simple and I even told you how.
>I wouldn't have posted such a question.
Just because you ask a question doesn't mean the solution isn't simple.
>An add-on such as this is available in FireFox,
Then someone wasted a lot of time on making something for Firefox that
is trivial to do without a plug-in/add on.
>which supports tabbed browsing. This add-on would concatenate the dev.. URL,
keep the path and file name, but replace the domain.
I can do that with a bookmark, add it to the toolbar. Why do I need an
addon?
>Get it?
I got it the first time I answered you. You are the one trying to make
it more difficult than it is.
>If you don't collaborate with end-users, I doubt you'd understand
why there's a need for such an add-on,
I "collaborate" with my end-users on a daily basis. Most times I
"collaborate" with them more than I wanted to.
x=document.location;
k = x.href.substring(8);
//change the 8 to pick up the parts you want to keep.
y = x.href.substring(0,8);
//change the 8 to pick up the live domain that you want to discard.
if(y="liveURLHere")
{x.href="devURLHere" + filePath}
else
{x.href="liveURLHere" + filePath}
Substitute the devURL and the liveURL, remove the comments, put it all
on one line, save it as a bookmarklet, add it to the IE toolbar.
Now, since you "Get it" and you seem to think I don't. Can you please
explain to me, and anybody else reading, why I need to install an addon
(to any browser) to allow me to do what the above bookmarklet will do?
OK, I've used the wrong terminology and that's why you're viewing this
as superfluous-I at least that's why I've interpreted this as. Instead
of add-on, I should have said IE Toolbar button, but not a favorite.

Why though? Why won't a favorite work if it can be coded to work?
I did as you suggested, with the code pasted above, and the script
host returned an error: "'window is undefined'."

That is an odd error as nothing in the script tried to access a "window".
It's possible that I didn't describe this requirement of the script. I
would need the script to understand that the path and filename will
not be the same in all instances.

I understood that part :-)
Sometimes you'd visithttp://www.live.com/file-path-name.jspand
want to switch to it's respective development page, but other
instances the file and path name would behttp://www.live.com/ff2-pp2-nn2.jsp,
and I would need the script to recognize the path and file name,
capture it, (or whatever function JS could provide in such a
situation), and replace the live domain (http://www.live.com)
with the development domain (http://live.dev.live.com).

If all you want to change is the domain of the page, no sub folders,
then you simply read the document.domain property which gives you thewww.live.com(or live.dev.live.com part) of the URL. You check that to
see which it is - live or dev - and replace it with the other, then set
location.href of the current page. The snippet I posted before had a
flaw where it assumed (incorrectly) that the domain names would be the
same length when that isn't always true.

//set a variable to the location.href property
k=location.href;
//read the domain
m=document.domain;
//define a variable for each domain name
n="www.live.com";
p="live.dev.live.com";
//check the domain to see which it is and branch accordingly
if(document.domain == n){
//replace the domain name in k with the new domain name
k=k.replace(m,p);}else{

//replace the domain name in k with the domain name of p
k=k.replace(m,n)}

//k now equals a string that represents the new URL so
//set the location.href property to k
location.href = k;

When you strip out the comments, remove the linebreaks, and add the
javascript: protocol to it, you end up with this:

javascript:k=location.href;m=document.domain;n="ww w.live.com";p="live.dev.live.com";if(document.doma in==n){k=k.replace(m,p);}else{k=k.r*eplace(m,n)}lo cation.href=k;

Save it as a bookmark.
Edit the n and p variables to match your respective domain names.

I don't have two live servers that I can tinker with right now to
thoroughly test it with but testing with variables instead of
location.href and document.domain I can't get it to fail in IE7. Try it
and if it still throws an error then let me know what the error was and
I will look into it some more. Whether you use a bookmark written in
javascript or any other language the process is the same.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/- Hide quoted text -

- Show quoted text -
The message I'm receiving is 'location is undefined.' I've saved the
file as a .js file, and placed it in Internet Explorer's Favorites
folder. Should this be an html file?

Thanks.

Jun 14 '07 #7

P: n/a
Danny said the following on 6/14/2007 10:25 AM:
On Jun 13, 5:52 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>Danny said the following on 6/13/2007 2:04 PM:
>>On Jun 13, 12:54 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
<snip>
>When you strip out the comments, remove the linebreaks, and add the
javascript: protocol to it, you end up with this:

javascript:k=location.href;m=document.domain;n="w ww.live.com";p="live.dev.live.com";if(document.dom ain==n){k=k.replace(m,p);}else{k=k.r*eplace(m,n)}l ocation.href=k;
<snip>
The message I'm receiving is 'location is undefined.' I've saved the
file as a .js file, and placed it in Internet Explorer's Favorites
folder. Should this be an html file?
No, the above code, that begins with javascript: is the URL of a favorites.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 16 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.