473,654 Members | 3,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Choose code to run based on incoming URL

Can I use a bookmark to selectively choose the code to be run?

For example. Suppose we have the following in an HTML file:

<html>

<head>

<script language="JavaS cript"><!--

location.href = 'HKlinks.html#B '

//--></script>

<noscript>

<meta http-equiv="Refresh" content="3;url= HowardKaikowSer vices.html">

</noscript>

</head>

</html>

And hklinks.html has:

<html>

<head>

<a name="A"><scrip t language="JavaS cript"><!--

location.href = 'HowardKaikow.h tml'

//--></script></a>

<a name="B"><scrip t language="JavaS cript"><!--

location.href = HowardKaikowSer vices.html'

//--></script></a>

<noscript>

<meta http-equiv="Refresh" content="3;url= index.html">

</noscript>

</head>

</html>

I want to choose which javascript to run based on the incoming link.

I tried onload.target to choose, but I think I screwed up the sintax.
--
http://www.standards.com/; See Howard Kaikow's web site.
Jul 23 '05 #1
14 2569
"Howard Kaikow" <ka****@standar ds.com> wrote in message
news:ck******** **@pyrite.mv.ne t...
Can I use a bookmark to selectively choose the code to be run?

For example. Suppose we have the following in an HTML file:

<html>

<head>

<script language="JavaS cript"><!--

location.href = 'HKlinks.html#B '

//--></script>

<noscript>

<meta http-equiv="Refresh" content="3;url= HowardKaikowSer vices.html">

</noscript>

</head>

</html>

And hklinks.html has:

<html>

<head>

<a name="A"><scrip t language="JavaS cript"><!--

location.href = 'HowardKaikow.h tml'

//--></script></a>

<a name="B"><scrip t language="JavaS cript"><!--

location.href = HowardKaikowSer vices.html'

//--></script></a>

<noscript>

<meta http-equiv="Refresh" content="3;url= index.html">

</noscript>

</head>

</html>

I want to choose which javascript to run based on the incoming link.

I tried onload.target to choose, but I think I screwed up the sintax.
--
http://www.standards.com/; See Howard Kaikow's web site.


How about the following instead?

<html>
<head>
<script type="text/javascript">
location.href = "HKlinks.html?B ";
</script>
<noscript>
<meta http-equiv="Refresh" content="3;url= HowardKaikowSer vices.html">
</noscript>
</head>
</html>
<html>
<head>
<script type="text/javascript">
var loc = location.search ;
if (loc == "?A") location.href = "HowardKaikow.h tml";
if (loc == "?B") location.href = "HowardKaikowSe rvices.html";
</script>
<noscript>
<meta http-equiv="Refresh" content="3;url= index.html">
</noscript>
</head>
</html>
Jul 23 '05 #2
On Thu, 07 Oct 2004 11:50:34 GMT, McKirahan <Ne**@McKirahan .com> wrote:

[snip]
I want to choose which javascript to run based on the incoming link.

[snip]
How about the following instead?


Since we're only talking about redirection, why not do it the proper way.
With the server.

[snip]

Mike
Please trim quotes!

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3
"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:opsfh00z0b x13kvk@atlantis ...
On Thu, 07 Oct 2004 11:50:34 GMT, McKirahan <Ne**@McKirahan .com> wrote:

[snip]
I want to choose which javascript to run based on the incoming link.

[snip]
How about the following instead?


Since we're only talking about redirection, why not do it the proper way.
With the server.


Because my ISP limits what we can do and even then discourages server side
stuff.

I could use a custom 404 file, but I want to try javascript first.
[snip]

Mike
Please trim quotes!

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.

Jul 23 '05 #4
Thanx, I'll give it a try.

--
http://www.standards.com/; See Howard Kaikow's web site.
"McKirahan" <Ne**@McKirahan .com> wrote in message
news:e4a9d.2048 33$D%.55378@att bi_s51...
"Howard Kaikow" <ka****@standar ds.com> wrote in message
news:ck******** **@pyrite.mv.ne t...
Can I use a bookmark to selectively choose the code to be run?

For example. Suppose we have the following in an HTML file:

<html>

<head>

<script language="JavaS cript"><!--

location.href = 'HKlinks.html#B '

//--></script>

<noscript>

<meta http-equiv="Refresh" content="3;url= HowardKaikowSer vices.html">

</noscript>

</head>

</html>

And hklinks.html has:

<html>

<head>

<a name="A"><scrip t language="JavaS cript"><!--

location.href = 'HowardKaikow.h tml'

//--></script></a>

<a name="B"><scrip t language="JavaS cript"><!--

location.href = HowardKaikowSer vices.html'

//--></script></a>

<noscript>

<meta http-equiv="Refresh" content="3;url= index.html">

</noscript>

</head>

</html>

I want to choose which javascript to run based on the incoming link.

I tried onload.target to choose, but I think I screwed up the sintax.
--
http://www.standards.com/; See Howard Kaikow's web site.


How about the following instead?

<html>
<head>
<script type="text/javascript">
location.href = "HKlinks.html?B ";
</script>
<noscript>
<meta http-equiv="Refresh" content="3;url= HowardKaikowSer vices.html">
</noscript>
</head>
</html>
<html>
<head>
<script type="text/javascript">
var loc = location.search ;
if (loc == "?A") location.href = "HowardKaikow.h tml";
if (loc == "?B") location.href = "HowardKaikowSe rvices.html";
</script>
<noscript>
<meta http-equiv="Refresh" content="3;url= index.html">
</noscript>
</head>
</html>

Jul 23 '05 #5
How do I modify the code to handle both ? and # as bookmark delimiters?

For example, in:
<html>
<head>
<p><a href="HKlinks.h tml?B">B?</a></p>
<p><a href="HKlinks.h tml?A">A?</a></p>
<p><a href="HKlinks.h tml#B">B#</a></p>
<p><a href="HKlinks.h tml#A">A#</a></p>
</head>
</html>

Only the links using ? work.
I commonly see # used instead f ? to separate the bookmark.
What modifications are needed in the following HKlinks.html?
<html>
<head>
<script type="text/javascript"><!--
var loc=location.se arch;
if(loc=="?A")lo cation.href="Ho wardKaikow.html ";
if(loc=="?B")lo cation.href="Ho wardKaikowServi ces.html";
//--></script>
<noscript>
<meta http-equiv="Refresh" content="3;url= index.html">
</noscript>
</head>
</html>
Jul 23 '05 #6
"Howard Kaikow" <ka****@standar ds.com> wrote in message
news:ck******** **@pyrite.mv.ne t...
How do I modify the code to handle both ? and # as bookmark delimiters?

For example, in:
<html>
<head>
<p><a href="HKlinks.h tml?B">B?</a></p>
<p><a href="HKlinks.h tml?A">A?</a></p>
<p><a href="HKlinks.h tml#B">B#</a></p>
<p><a href="HKlinks.h tml#A">A#</a></p>
</head>
</html>

Only the links using ? work.
I commonly see # used instead f ? to separate the bookmark.
What modifications are needed in the following HKlinks.html?
<html>
<head>
<script type="text/javascript"><!--
var loc=location.se arch;
if(loc=="?A")lo cation.href="Ho wardKaikow.html ";
if(loc=="?B")lo cation.href="Ho wardKaikowServi ces.html";
//--></script>
<noscript>
<meta http-equiv="Refresh" content="3;url= index.html">
</noscript>
</head>
</html>


First, you should no longer use "<!--" and "--> within <script> tags.

Second, your <a> tags go inside the <body> not the <head> section.

Thirdly, you have a solution with "?" why try to use "#"?

"#" are used for bookmarks (as you know).

"?" indicates a QueryString which can be interrogated by the called page.
Jul 23 '05 #7
Because when I gove somebody a URL, I usually give it as a web page and,
maybe, a bookmark on that web page, which is also how a lot of folkes are
used to seeing a URL.

I'll have no control whether they use a ? or a #.
Here's what I have in the .js file, but the part about the # is doing what I
need.

<html>
<head>
<script type="text/javascript", SRC ="links.js"> </script>
<noscript>
<HR>
<A href="index.htm l">The URL you used requires the use of JavaScript. If you
wish to use the URL,
please enable support for Javascript in your browser.
You will shortly be taken to http://www.standards.com/index.html, or you can
click here now.</A>
<HR>
<meta http-equiv="Refresh" content="0;url= index.html">
</noscript>
</head>
</html>

The following is currently the link.js file.

var loc=location.se arch.toUpperCas e();
if((loc=="?A")| |(loc=="#A")){
location.href=" HowardKaikow.ht ml";
}
else if((loc=="?B")| |(loc=="#B")){
location.href=" HowardKaikowSer vices.html";
}
else{
alert(location. href + " is not a valid URL.\n" +
"You will be taken to http://www.standards.c om/index.html.");
location.href=" index.html";
}
--
http://www.standards.com/; See Howard Kaikow's web site.
"McKirahan" <Ne**@McKirahan .com> wrote in message
news:ZZa9d.1979 17$MQ5.6432@att bi_s52...
"Howard Kaikow" <ka****@standar ds.com> wrote in message
news:ck******** **@pyrite.mv.ne t...
How do I modify the code to handle both ? and # as bookmark delimiters?

For example, in:
<html>
<head>
<p><a href="HKlinks.h tml?B">B?</a></p>
<p><a href="HKlinks.h tml?A">A?</a></p>
<p><a href="HKlinks.h tml#B">B#</a></p>
<p><a href="HKlinks.h tml#A">A#</a></p>
</head>
</html>

Only the links using ? work.
I commonly see # used instead f ? to separate the bookmark.
What modifications are needed in the following HKlinks.html?
<html>
<head>
<script type="text/javascript"><!--
var loc=location.se arch;
if(loc=="?A")lo cation.href="Ho wardKaikow.html ";
if(loc=="?B")lo cation.href="Ho wardKaikowServi ces.html";
//--></script>
<noscript>
<meta http-equiv="Refresh" content="3;url= index.html">
</noscript>
</head>
</html>


First, you should no longer use "<!--" and "--> within <script> tags.

Second, your <a> tags go inside the <body> not the <head> section.

Thirdly, you have a solution with "?" why try to use "#"?

"#" are used for bookmarks (as you know).

"?" indicates a QueryString which can be interrogated by the called page.

Jul 23 '05 #8
"Howard Kaikow" <ka****@standar ds.com> wrote in message
news:ck******** **@pyrite.mv.ne t...
Here's what I have in the .js file, but the part about the # is doing what I need.
I meant to say "but the part about the # NOT is doing what I need".


<html>
<head>
<script type="text/javascript", SRC ="links.js"> </script>
<noscript>
<HR>
<A href="index.htm l">The URL you used requires the use of JavaScript. If you wish to use the URL,
please enable support for Javascript in your browser.
You will shortly be taken to http://www.standards.com/index.html, or you can click here now.</A>
<HR>
<meta http-equiv="Refresh" content="0;url= index.html">
</noscript>
</head>
</html>

The following is currently the link.js file.

var loc=location.se arch.toUpperCas e();
if((loc=="?A")| |(loc=="#A")){
location.href=" HowardKaikow.ht ml";
}
else if((loc=="?B")| |(loc=="#B")){
location.href=" HowardKaikowSer vices.html";
}
else{
alert(location. href + " is not a valid URL.\n" +
"You will be taken to http://www.standards.c om/index.html.");
location.href=" index.html";
}
--
http://www.standards.com/; See Howard Kaikow's web site.
"McKirahan" <Ne**@McKirahan .com> wrote in message
news:ZZa9d.1979 17$MQ5.6432@att bi_s52...
"Howard Kaikow" <ka****@standar ds.com> wrote in message
news:ck******** **@pyrite.mv.ne t...
How do I modify the code to handle both ? and # as bookmark delimiters?
For example, in:
<html>
<head>
<p><a href="HKlinks.h tml?B">B?</a></p>
<p><a href="HKlinks.h tml?A">A?</a></p>
<p><a href="HKlinks.h tml#B">B#</a></p>
<p><a href="HKlinks.h tml#A">A#</a></p>
</head>
</html>

Only the links using ? work.
I commonly see # used instead f ? to separate the bookmark.
What modifications are needed in the following HKlinks.html?
<html>
<head>
<script type="text/javascript"><!--
var loc=location.se arch;
if(loc=="?A")lo cation.href="Ho wardKaikow.html ";
if(loc=="?B")lo cation.href="Ho wardKaikowServi ces.html";
//--></script>
<noscript>
<meta http-equiv="Refresh" content="3;url= index.html">
</noscript>
</head>
</html>


First, you should no longer use "<!--" and "--> within <script> tags.

Second, your <a> tags go inside the <body> not the <head> section.

Thirdly, you have a solution with "?" why try to use "#"?

"#" are used for bookmarks (as you know).

"?" indicates a QueryString which can be interrogated by the called page.


Jul 23 '05 #9
"Howard Kaikow" <ka****@standar ds.com> wrote in message
news:ck******** **@pyrite.mv.ne t...
Because when I gove somebody a URL, I usually give it as a web page and,
maybe, a bookmark on that web page, which is also how a lot of folkes are
used to seeing a URL.

I'll have no control whether they use a ? or a #.
Here's what I have in the .js file, but the part about the # is doing what I need.

<html>
<head>
<script type="text/javascript", SRC ="links.js"> </script>
<noscript>
<HR>
<A href="index.htm l">The URL you used requires the use of JavaScript. If you wish to use the URL,
please enable support for Javascript in your browser.
You will shortly be taken to http://www.standards.com/index.html, or you can click here now.</A>
<HR>
<meta http-equiv="Refresh" content="0;url= index.html">
</noscript>
</head>
</html>

The following is currently the link.js file.

var loc=location.se arch.toUpperCas e();
if((loc=="?A")| |(loc=="#A")){
location.href=" HowardKaikow.ht ml";
}
else if((loc=="?B")| |(loc=="#B")){
location.href=" HowardKaikowSer vices.html";
}
else{
alert(location. href + " is not a valid URL.\n" +
"You will be taken to http://www.standards.c om/index.html.");
location.href=" index.html";
}


First, you can change
if((loc=="?A")| |(loc=="#A")){
to
if(loc=="?A"||l oc=="#A"){
if you want.

Second, what do you mean that you "... have no control whether they use a ?
or a #" after you state "... when I gove [sic] somebody a URL". If you give
them a URL it has what ever suffix you include; such as "?A".

Thirdly, it still isn't clear what your really trying to accomplish (big
picture).

It isn't clear why you need to use "#"; is it that you want to jump "into" a
page and not just "to" a page?

Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
26838
by: | last post by:
Is it possible to construct a CDO.To statement based on the value of an incoming form drop down list which contains any word such as "ChangeStatus:" How would I construct the IF statement to isolate the 'string' in the incoming variable to allow a branching statement: If Request.form("ChangeStatue") containts the string "Sales Alert" Then '// Else
6
1945
by: Penny | last post by:
Hi all, I've built a simple search <Form> on a web page that is intended to allow the user to search a record store database. There is a drop down box where the user can choose either 'Artist' or 'Title', next is a text box where they enter their 'Keyword' and next is the search button. For example the user may choose 'Artist', type 'Bob Dylan', click the search button and be presented with a page showing all the details of the Bob...
16
8493
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
12
1668
by: anna | last post by:
Map, generate, and maintain 50% of your .NET application code, namely your business and data objects. Use these objects in ASP.NET, Windows Forms, console or services applications. Business and Data Objects Framework -- Map objects to relational databases -- Embed SQL, stored procedure calls, and business rules -- Generate .NET components in C# and VB.NET -- Use components in your own high-traffic custom applications
1
2181
by: relisoft | last post by:
SEATTLE, Washington. - July 12, 2006: Reliable Software® announces the upcoming release of Code Co-op® version 5.0. Code Co-op is an affordable peer-to-peer version control system for distributed development enabling collaboration through Email, LAN, or VPN-no server required. The upcoming release of Code Co-op 5.0 is due out this fall. With this release Reliable Software continues its track record of innovation by introducing...
11
1986
by: Genalube | last post by:
I am new to access, so I figure this is an easy question to answer. I just can't find it on my own. Background: Two tables with a one to many relationship (irelevantField1 is a place holder, these fields are not relevant to posting, the number of fields represented is correct) Parcels: ParcelNo irelevantField1 irelevantField2
5
2629
by: Jens | last post by:
Hello, I have been looking for some C-code which listens on a user-defined port for incoming data traffic. When data is received, the data is written to a file. I found some C-code (server) that almost does the job. It listens on a user-defined port and responds to incoming data by writing how many times somebody has tried to connect to the server.
4
4072
by: Morgan Cheng | last post by:
Since ASP.NET 2.0, asynchronous web service client can be implemented with event-based pattern, instead of original BeginXXX/EndXXX pattern. However, I didn't find any material about event-based server side asynchronous web service. So, we can only implement asynchronous webmethod with BeginXXX/EndXXX pattern, right? I don't why ASP.NET 2.0 don't provide event-based server side pattern.
1
2440
by: gozlemci | last post by:
Hi everybody; During my coding, I have encountered a problem.I appreciate if anybody answer it. Here is the simplified code: //Header5.h #pragma once #include <string> using namespace std;
0
8379
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8294
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8494
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2719
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1597
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.