473,557 Members | 2,803 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Go directly to desired page, in JavaScript

Hello everyone,

I would like to let visitors of my website be able to go directly to a
desired page, by using a URL like www.example.com?progname. I thought I
could do this as follows:

<html>
<frameset rows="88,*">
<frame name="head" noresize src="head.htm" />
<frameset cols="152,*">
<frame name="menu" noresize src="menu.htm" />
<script language="JavaS cript">
prog = location.search
prog = prog.substr(1)
prog = prog.split("&")
if (prog=="prognam e") { document.write ("<frame name='body' noresize
src='progpage.h tm' />") }
else if (prog==...
....
else { document.write ('<frame name="body" noresize src="mainpage.h tm"
/>') }
</script>
</frameset>
</frameset>
</html>

I see that the above code doesn't produce a page for the body, but I can't
see why? Could anybody please tell me what I'm overlooking?

TIA and regards, Bert Visscher.
Jul 23 '05 #1
7 1443
Bert Visscher wrote on 10 aug 2004 in comp.lang.javas cript:
prog = prog.split("&")
if (prog=="prognam e") {


[follow up to: comp.lang.javas cript]

Dag Bert,

prog is not a string but an array.
If the calling url was:

http://mySite.nl/test.html?x=progname&y=blah

if (prog[0] == "x=progname ") {
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #2
On Tue, 10 Aug 2004 10:25:18 +0200, Bert Visscher wrote:
I would like to let visitors of my website..


URL?

BTW ... alive.internet. lang.javascript ,
(never heard of it..)
alt.comp.lang.j avascript,
(what a load of crap..)
comp.lang.java. javascript,
(not an official group..)
comp.lang.javas cript
(Ahhhh.. yes, this is where the JS gurus reside)

Please do not cross-post to 4 separate groups..
You may think your problem is that important,
others know it is not.
<http://www.physci.org/codes/javafaq.jsp#xpo st>

Follow ups for this thread set to c.l.js ONLY..

[ Please note that even to post *this* message to
four groups has my newsreader whining at me.. ]

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #3
Dag Evertjan,

The way I interpret your reply, the following code should work:

<html>
<frameset rows="88,*">
<frame name="kop" noresize src="kop.htm" />
<frameset cols="152,*">
<frame name="menu" noresize src="menu.htm" />
<script language="JavaS cript">
prog = location.search
prog = prog.substr(1)
prog = prog.split("&")
if (prog[0]=="gezondheidsl ijn") { document.write ("<frame name='body'
src='pi-gezondheidslijn .htm' />") }
else { document.write ("<frame name='body' src='hoofdpagin a.htm' />") }
</script>
</frameset>
</frameset>
</html>

I'm afraid it doesn't. Just like before, I see the top and left frame
appear, but there's no body.

TIA and regards, Bert V.

"Evertjan." <ex************ **@interxnl.net > schreef in bericht
news:Xn******** ************@19 4.109.133.29...
Bert Visscher wrote on 10 aug 2004 in comp.lang.javas cript:
prog = prog.split("&")
if (prog=="prognam e") {


[follow up to: comp.lang.javas cript]

Dag Bert,

prog is not a string but an array.
If the calling url was:

http://mySite.nl/test.html?x=progname&y=blah

if (prog[0] == "x=progname ") {
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 23 '05 #4
Bert Visscher wrote on 10 aug 2004 in comp.lang.javas cript:
"Evertjan." <ex************ **@interxnl.net > schreef in bericht
news:Xn******** ************@19 4.109.133.29...
Bert Visscher wrote on 10 aug 2004 in comp.lang.javas cript:
> prog = prog.split("&")
> if (prog=="prognam e") {


[follow up to: comp.lang.javas cript]

Dag Bert,

prog is not a string but an array.
If the calling url was:

http://mySite.nl/test.html?x=progname&y=blah

if (prog[0] == "x=progname ") {

The way I interpret your reply, the following code should work:

<html>
<frameset rows="88,*">
<frame name="kop" noresize src="kop.htm" />
<frameset cols="152,*">
<frame name="menu" noresize src="menu.htm" />
<script language="JavaS cript">
prog = location.search
prog = prog.substr(1)
prog = prog.split("&")
if (prog[0]=="gezondheidsl ijn") { document.write ("<frame
name='body'
src='pi-gezondheidslijn .htm' />") }
else { document.write ("<frame name='body' src='hoofdpagin a.htm'
/>") }
</script>
</frameset>
</frameset>
</html>

I'm afraid it doesn't. Just like before, I see the top and left frame
appear, but there's no body.


This
= if (prog[0]=="gezondheidsl ijn") =
would require zoiets als:
http://mySite.nl/test.html?gezondheidslijn&y=blah
This cannot be the output of a <form>

Do you get javascript errors ?

Please start debugging by inserting a handful of alert()s:

<frame name='body'
<script type="text/JavaScript"> // the 'language=' is depriciated
var prog = location.search
alert(prog) // is there a & in the string ???
prog = prog.substr(1)
alert(prog) // do you see the same without the '?' ?
prog = prog.split("&")
alert(prog[0]) // do you see 'gezondheidslij n' ?
if (prog[0]=="gezondheidsl ijn"){
alert('ja') // 'if' is given true
document.write( "src='pi-gezondheidslijn .htm'")
}
else {
alert('nee') // false
document.write( "src='hoofdpagi na.htm'")
}
</script>
/>

Are the two links correct ?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #5

"Evertjan." <ex************ **@interxnl.net > schreef in bericht
news:Xn******** ************@19 4.109.133.29...
Bert Visscher wrote on 10 aug 2004 in comp.lang.javas cript:
"Evertjan." <ex************ **@interxnl.net > schreef in bericht
news:Xn******** ************@19 4.109.133.29...
Bert Visscher wrote on 10 aug 2004 in comp.lang.javas cript:
> prog = prog.split("&")
> if (prog=="prognam e") {

[follow up to: comp.lang.javas cript]

Dag Bert,

prog is not a string but an array.
If the calling url was:

http://mySite.nl/test.html?x=progname&y=blah

if (prog[0] == "x=progname ") {

The way I interpret your reply, the following code should work:

<html>
<frameset rows="88,*">
<frame name="kop" noresize src="kop.htm" />
<frameset cols="152,*">
<frame name="menu" noresize src="menu.htm" />
<script language="JavaS cript">
prog = location.search
prog = prog.substr(1)
prog = prog.split("&")
if (prog[0]=="gezondheidsl ijn") { document.write ("<frame
name='body'
src='pi-gezondheidslijn .htm' />") }
else { document.write ("<frame name='body' src='hoofdpagin a.htm'
/>") }
</script>
</frameset>
</frameset>
</html>

I'm afraid it doesn't. Just like before, I see the top and left frame
appear, but there's no body.


This
= if (prog[0]=="gezondheidsl ijn") =
would require zoiets als:
http://mySite.nl/test.html?gezondheidslijn&y=blah
This cannot be the output of a <form>

Do you get javascript errors ?

Please start debugging by inserting a handful of alert()s:

<frame name='body'
<script type="text/JavaScript"> // the 'language=' is depriciated
var prog = location.search
alert(prog) // is there a & in the string ???
prog = prog.substr(1)
alert(prog) // do you see the same without the '?' ?
prog = prog.split("&")
alert(prog[0]) // do you see 'gezondheidslij n' ?
if (prog[0]=="gezondheidsl ijn"){
alert('ja') // 'if' is given true
document.write( "src='pi-gezondheidslijn .htm'")
}
else {
alert('nee') // false
document.write( "src='hoofdpagi na.htm'")
}
</script>
/>

Are the two links correct ?


Hoi Evertjan,

I flipped a couple of quotes, and ended up with the following complete code:

<html>
<frameset rows="88,*">
<frame name="kop" noresize src="kop.htm" />
<frameset cols="152,*">
<frame name="menu" noresize src="menu.htm" />
<frame name="body"
<script type="text/JavaScript">
var prog = location.search
alert(prog) // is there a & in the string ???
prog = prog.substr(1)
alert(prog) // do you see the same without the '?' ?
prog = prog.split("&")
alert(prog[0]) // do you see 'gezondheidslij n' ?
if (prog[0]=="gezondheidsl ijn")
{
alert("ja") // 'if' is given true
document.write( 'src="pi-gezondheidslijn .htm"')
}
else
{
alert("nee") // false
document.write( 'src="hoofdpagi na.htm"')
}
</script>
/>
</frameset>
</frameset>
</html>

I think we're getting closer:
This time around, regardless of whether I add "?gezondheidsli jn", I get a
body...but it stays blank. And, as if that's not curious enough, I'm not
getting any of the alerts.

Oh, I nearly forgot to write that I'm not getting any error messages.

TIA and regards, Bert V.
Jul 23 '05 #6
Bert Visscher wrote on 12 aug 2004 in comp.lang.javas cript:
I think we're getting closer:
This time around, regardless of whether I add "?gezondheidsli jn", I
get a body...but it stays blank. And, as if that's not curious enough,
I'm not getting any of the alerts.

Oh, I nearly forgot to write that I'm not getting any error messages.


Tja, Bert, dan wordt de hele script niet uitgevoerd in een frame
declaratie!!!

Dit werkt wel:

<html>

<script type="text/JavaScript">
function kies(x){
myBody.location .href=
(location.searc h.substr(1).spl it("&")[0]==
"gezondheidslij n")
?"pi-gezondheidslijn .htm":"hoofdpag ina.htm"
}
</script>

<frameset rows="88,*" onLoad="kies()" >
<frame name="kop" noresize src="kop.htm" />
<frameset cols="152,*">
<frame name="menu" noresize src="menu.htm" />
<frame name="myBody" />
</frameset>
</frameset>

</html>

[ik heb de code sterk verkort en de naam "body" vervangen,
omdat dat soms een "reserved word" zou kunnen zijn.]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #7
> I think we're getting closer:
This time around, regardless of whether I add "?gezondheidsli jn", I get a
body...but it stays blank. And, as if that's not curious enough, I'm not
getting any of the alerts.

Oh, I nearly forgot to write that I'm not getting any error messages.

TIA and regards, Bert V.


I had a similar problem. I got it to work with iframes using the
following:

<script language="JavaS cript">
page = "main.htm"; //default page
if(location.sea rch) page = location.search .substring(1);

//insert extra logic here if want

document.write( '<iframe src="' + page + '" id="myIframe"
name="myIframe" width="630" scrolling="no"
frameborder="1" ></iframe>');
</script>

You could add logic in there, like:

if (page = "help") page = help.html;

I hope this helps.

Jim
Jul 23 '05 #8

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

Similar topics

5
1886
by: Laphan | last post by:
Hi All I've been looking at having my Javascript file as an ASP one to try and stop general prying eyes, eg: <SCRIPT LANGUAGE="javascript" SRC="js-something.asp"> </SCRIPT> and this seems to work well apart from the fact that if the user, puts in for example:
1
2566
by: Wladimir Borsov | last post by:
I want to mark certain text on a web page in InternetExplorer and then copy and paste it into a normal text editor. With the copied text not only the pure text should be transferred but also the HTML code (e.g. <P>,<HL>,<TABLE>,CSS styles,...). Is there such a tool? No, I don't want to open the source code of the webpage through the menu...
6
2486
by: David | last post by:
Ok. Can PHP control a form value directly? Eg. like the javascript "document.Form1.text01.value = "Y"". Eg. allow me to put a value into a form text field on page load. Either I missed this in my PHP book or the function does not exist. The only way I have seen is to put code in the value part of the input item, see below. Thanks
2
14249
by: AP No spam | last post by:
Hi I need help to Print Pdf File directly without preview from client side To solve problem I used This C# code Response.Buffer = true;
4
8084
by: Dica | last post by:
i've got a dropdown list with various options added to it. i want to add a button that allows the user to "Add New Option' which should create a blank row on the dropdown list and allow the user to type directly into it. is this possible?
5
3108
by: Tim Walters | last post by:
My web page was put together by the Spanish yellow pages company (closely associated with -- but don't ask me how -- with the ISP Telefonica). I can access the page by going to the yellow pages homepage, and typing in the name in the "Firm" box. But if I try introducing the URL directly in the address field of IE or Opera, I get an "Under...
38
3986
by: Neo Geshel | last post by:
I am seeking a method to load one JS file directly into another, *without* having to dynamically write <scripttags. Is there any method whereby I can call only one external JS file using a single <scripttag, but have that external JS file insert into ITSELF the contents of five others? Something like: /*start external.js*/
0
7626
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...
0
7830
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. ...
0
8061
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7911
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...
1
5454
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...
0
5172
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1161
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
867
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...

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.