473,609 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

query_string <base> JS

Hello:

I have this one line of PHP code which I'd like to convert to Javascript.
The PHP code conditionally issues a BASE statement when the html page
is called with a frame name, e.g. href=index2.php ?frame2

<html>
<head>
<? $tag = $_SERVER["QUERY_STRI NG"]; if(empty($tag)) {; } else { echo "<base target=$tag>"; } ?>
</head>
<body> . . . .

The problem is that I don't have PHP on my system and can't view the page,
unless I upload it to the server. I'd like to replace the php code with
javascript, but I don't know much about either php or JS. I've been
looking all over for an hour but haven't found the solution. Can one of
you get me started? Thanks.

Jul 23 '05 #1
3 1617
Ivo
"Gilbert Saint-Flour" asked:
I have this one line of PHP code which I'd like to convert to Javascript.
The PHP code conditionally issues a BASE statement when the html page
is called with a frame name, e.g. href=index2.php ?frame2

<html>
<head>
<? $tag = $_SERVER["QUERY_STRI NG"]; if(empty($tag)) {; } else { echo "<base target=$tag>"; } ?> </head>
<body> . . . .

The problem is that I don't have PHP on my system and can't view the page,
unless I upload it to the server. I'd like to replace the php code with
javascript, but I don't know much about either php or JS. I've been
looking all over for an hour but haven't found the solution. Can one of
you get me started? Thanks.


Replacing php with javascript? Usually the request is the other way around,
because servers may or may not run PHP, but at least you know, while
end-users may or may not have javascript, and you will never know.
A javascript that would do what the above does:

if (location.searc h) {
var ls = document.links;
for(var i=ls.length;i--;) ls.target=locat ion.search.subs tring(1);
}

This code must not run before all links in the document have loaded, so
either onload or after the body content (but to validate it must be before
the end body tag).
HTH
Ivo
Jul 23 '05 #2
Ivo
"Ivo" wrote
if (location.searc h) {
var ls = document.links;
for(var i=ls.length;i--;) ls.target=locat ion.search.subs tring(1);
That should have been
for(var i=ls.length;i--;) ls[i].target=locatio n.search.substr ing(1);
of course
I
}


Jul 23 '05 #3
Gilbert Saint-Flour wrote:
Hello:

I have this one line of PHP code which I'd like to convert to Javascript.
The PHP code conditionally issues a BASE statement when the html page
is called with a frame name, e.g. href=index2.php ?frame2

<html>
<head>
<? $tag = $_SERVER["QUERY_STRI NG"]; if(empty($tag)) {; } else { echo "<base target=$tag>"; } ?>
</head>
<body> . . . .


<head>
<script type="text/JavaScript">
if(x=location.s earch.toString( )){
document.write( "<base target="+x.subs tring(1)+">")
}
</script>
Mick
Jul 23 '05 #4

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

Similar topics

7
9204
by: Weston C | last post by:
I'm trying to get the href attribute from the base tag in the document head. The following does not seem to work... any ideas what I'm doing wrong? if(!(document.getElementsByTagName) || !(basehrefs = document.getElementsByTagName('base')) || !(basehrefs.length) || !(basehrefs.length > 0) || !(basehrefs.getAttribute) || !(basehref = basehrefs.getAttribute('href')) )
2
1936
by: CD | last post by:
Is this possible: class base; class derived; //:public base vector <base*> bList; vector<derived*> dList; //add some derived class pointer entries to dList;
2
2096
by: Siemel Naran | last post by:
This code fails compile std::auto_ptr<Base> f() { std::auto_ptr<Derived> out(new Derived()); return out; } There is ambiguity between a templated constructor and templated operator conversion, according to my compiler. Seems there are too many constructors and operator conversions. But this code works:
1
2715
by: Chris Sharman | last post by:
I'm seeing quite a few 404 errors, all from an agent/browser which calls itself "Mozilla/4.0 (compatible; BorderManager 3.0)". They appear to be from a built page like http://services.ccagroup.co.uk/upbin/oformw?&whsmithwedding (no referrer supplied, so I can't be certain), which contains <base href="http://www.ccagroup.co.uk/whsmithwedding/"> in the head, and references to several images eg "media/pg03/bgrnd.gif" in the body. This...
3
4580
by: SJ | last post by:
Hi, I have a problem with the HTML <base> element, URL re-writing and Postback. We are using URL re-writing on the server, and I'd like to use the base element to make the URLs in the ASPX pages more maintainable. Otherwise, we have to manually output the application root eg. src="<%= AppRoot %>". This is cumbersome and hard to maintain. However, there seems to be no way - apart from a client-side script - to rewrite the action...
0
1485
by: emma_middlebrook | last post by:
Hi Hopefully the title is quite accurate but here's some more information. I have a load of ICollection<references hanging off a class e.g. ICollection<X>, ICollection<Yetc etc. Each of the collection's types are all derived from a base class Base i.e X : Base, Y : Base etc etc.
3
12843
by: yan | last post by:
Hello everybody, I am new so this is the occasion to say hello to everybody. I have a problem with absolute/relative paths. I have to create a static documentation in html for a project and I have to create an index page in every sub-directory. The structure is like the following: / /sources/ /docs/ /docs/doc1 /share
16
2386
by: call_me_anything | last post by:
why is the following not allowed : vector <Base *vec_of_base; vector <Derived *vec_of_derived; vec_of_base = vec_of_derived; Note : The following is allowed :
0
8115
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
8557
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...
0
8513
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8380
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...
1
6047
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...
0
5504
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1638
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1374
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.