hi,
i would like to know how i can evaluate the current url so that either javascript :history.go(-1)'or javascript :history.go(-2) is executed. I would like for the javascript :history.go(-2) to be executed if the url is suffixed with the "#top"... like http://localhost...#top. I currently have: -
echo "<A HREF='javascript:javascript:history.go(-1)'>HOME</A><br><br>";
-
thanks in advance,
geebee
22 2642
now i have: -
-
<html>
-
-
<BODY>
-
-
<SCRIPT LANGUAGE="JavaScript">
-
-
function showLoc()
-
{
-
var x = window.location;
-
-
if (x = "http://httplocalhost/checkurl.html")
-
{
-
document.write("<a href='http://www.microsoft.com'>go to microsoft</a>");
-
}
-
else
-
{
-
document.write "stay here"
-
}
-
-
var t = ['Property - Typeof - Value',
-
'window.location - ' + (typeof x) + ' - ' + x ];
-
for (var prop in x){
-
t.push(prop + ' - ' + (typeof x[prop]) + ' - ' + (x[prop] || 'n/a'));
-
}
-
alert(t.join('\n'));
-
}
-
</SCRIPT>
-
-
-
-
</html>
-
but its not doing anything...
saying "error on page" at the bottom of the window.
Dormilich 8,658
Recognized Expert Moderator Expert
firstly, window.location is an object, not a string. secondly, there's a syntax error in line 18 (missing brackets) and probably the wrong operator on line 12. thirdly, javascript should be served with a type declaration in the <script> tag.
ok..
i figure it out.. here is my code... appearing at the bottom after the PHP code: -
<SCRIPT LANGUAGE="JavaScript">
-
function showLoc()
-
{
-
var x = window.location;
-
if (x == "http://localhost/checkurl.html")
-
{
-
document.write("<a href='http://www.microsoft.com'>go to microsoft</a>");
-
}
-
else
-
{
-
document.write ("stay here")
-
}
-
-
}
-
-
x=0;
-
document.self.location.reload();
-
</SCRIPT>
-
the only problem now is i cant figure out how to get the document.write results after the results of my PHP are listed. i tried <BODY ONLOAD = ...> but that only lists the document.write output from the javascript.
thanks in advance,
geebee
Dormilich 8,658
Recognized Expert Moderator Expert @geraldjr30
what PHP code?
just out of interest, do you ever enter the first statement in the if clause?
yes, i entered the first line of the IF statement. but it only works if i have the <BODY ONLOAD = showLoc()..> and then my PHP output does not display. only the document.write output from the javascript function displays. i want the PHP results to display as a result of my PHP code (not posted here because it is irrelevant i think), and then the document.write from the javascript function to be displayed beneath that.
thanks in advance,
geebee
Dormilich 8,658
Recognized Expert Moderator Expert @geraldjr30
obviously.... the output is defined in a function after all @geraldjr30
then there is something wrong with your PHP code.
acoder 16,027
Recognized Expert Moderator MVP @geraldjr30
document.write reopens the document for writing, so don't use it after the page has loaded. Either use DOM methods, set innerHTML of an element or use it during page load only.
ok... i think im almost there..
i have.. -
<?php>
-
...
-
...
-
?>
-
-
<SCRIPT LANGUAGE="JavaScript">
-
function showLoc()
-
{
-
var x = window.location;
-
if (x == "http://localhost/REC.php?count=sunday&fac=des&SRG_GROUP=Charity")
-
{
-
-
document.body.innerHTML += "<a href=\"http://www.AOL.com\">AOL</a>";
-
}
-
else
-
{
-
document.body.innerHTML += "<a href=\"http://www.msn.com\">MICROSOFT</a>";
-
}
-
}
-
</SCRIPT>
-
but neither AHREF is being shown on the page...
thanks in advance,
geebee
acoder 16,027
Recognized Expert Moderator MVP
Are you calling showLoc body onload?
now i am calling it on BODY load.. but the MICROSOFT link is appearing. The url in the address bar is http://localhost/REC.php?count=sunda..._GROUP=Charity
so it should be listing the AOL link instead... am i evaluating the current url wrong? once again my code is... -
<SCRIPT LANGUAGE="JavaScript">
-
function showLoc()
-
{
-
var x = window.location;
-
if (x == "http://localhost/REC.php?count=sunday&fac=DES&SRG_GROUP=Charity")
-
{
-
-
document.body.innerHTML += "<a href=\"http://www.AOL.com\">AOL</a>";
-
}
-
else
-
{
-
document.body.innerHTML += "<a href=\"http://www.msn.com\">MICROSOFT</a>";
-
}
-
}
-
</SCRIPT>
-
thanks in advance,
geebee
Dormilich 8,658
Recognized Expert Moderator Expert
try this one: - if (x.href == "http://localhost/REC.php?count=sunday&fac=DES&SRG_GROUP=Charity")
ok thanks... that works!!!! now all i need to figure out is to evaluate whether or not the url in the address bar is suffixed with "#top", as there may be any day followed by the word "count" in the url, and i would rather not have an if statement for ever day of the week. how would i amend this?
thanks in advance,
geebee
Dormilich 8,658
Recognized Expert Moderator Expert @geraldjr30
I've told you about that problem already in post #4 (and #6)........ @geraldjr30
use window.location.hash (see post #2)
regards
it works... but no matter how hard i try, i cant get the MICROSOFT or AOL link to appear at the top of the page... it appears off to the side of the PHP output... -
<BODY onload="showLoc();">
-
-
-
<SCRIPT LANGUAGE="JavaScript">
-
function showLoc()
-
{
-
var x = window.location.hash;
-
if (x == "#top")
-
{
-
-
document.body.innerHTML += "<a href=\"http://www.AOL.com\">AOL</a>";
-
}
-
else
-
{
-
document.body.innerHTML += "<a href=\"http://www.msn.com\">MICROSOFT</a>";
-
}
-
}
-
</SCRIPT>
-
thanks in advance,
geebee
Dormilich 8,658
Recognized Expert Moderator Expert
it will be appended at the end.... looks like it. to get it on the top either use DOM methods to include the links or a different styling.
thanks...
how i get the page to refresh with the following: -
echo "<td width = '100' height = '10'><br><a href='#top'>back to top</a></td>";
-
thanks in advance,
geebee
Dormilich 8,658
Recognized Expert Moderator Expert
besides clicking on the link?
i want it to refresh when you click on the #top link
Dormilich 8,658
Recognized Expert Moderator Expert
ah, try with the whole url. like href="localhost/this_page.htm#top".
will this work even if the url parameters are changed? like the url for this page could change depending on the form values posted to it from the previous page.
Dormilich 8,658
Recognized Expert Moderator Expert
if you send the values via POST then you don't need to worry. you can get the URL in PHP via the $_SERVER variable (just check out phpinfo()). if I remember right it's $_SERVER['REQUEST_URI']. but others may do as well.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: neblackcat |
last post by:
Would anyone like to comment on the following idea?
I was just going to offer it as a new PEP until it was suggested that
I post it here for comment & consideration against PEP 308.
I'm far...
|
by: Benjamin Niemann |
last post by:
Hello,
I've been just investigating IE conditional comments - hiding things from
non-IE/Win browsers is easy, but I wanted to know, if it's possible to hide
code from IE/Win browsers.
I found...
|
by: Jouke Langhout |
last post by:
Hello all!
For quite some time now, I've got the following problem:
Access won't close properly when a user closes the application. An
ACCESS process stays active and that process can only be...
|
by: Bradley |
last post by:
I have an A2000 database in which I have a continuous form with a tick
box. There is also a text box with a conditional format that is based on
the expression , if it's true then change the...
|
by: GGerard |
last post by:
Hello
Is there a way to use a variable in the Conditional Formatting of a Textbox?
Example :
I want the background of a textbox in a continuous form to change color when
the value of...
| |
by: John Dolinka |
last post by:
I have a project of several files with #defines to setup a conditional
compile. I would like to put these #defines in a single file and change the
conditional compile from this one file with the...
|
by: John Smith |
last post by:
After reading C# documentation the Conditional attribute seemed the way to
go, but after inspecting the IL it seems those methods are still there and I
imagine the CLR removes them. Using #if DEBUG...
|
by: Olov Johansson |
last post by:
I just found out that JavaScript 1.5 (I tested this with Firefox 1.0.7
and Konqueror 3.5) has support not only for standard function
definitions, function expressions (lambdas) and Function...
|
by: Typehigh |
last post by:
I have many text fields with conditional formatting applied,
specifically when the condition is "Field Has Focus". Without any
events associated with the fields the conditional formatting works...
|
by: paulo |
last post by:
Can anyone please tell me how the C language interprets the following
code:
#include <stdio.h>
int main(void)
{
int a = 1;
int b = 10;
int x = 3;
|
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...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |