Hello,
I'm trying to parse the referring url for google search terms so that when this page loads it will scroll to and highlight the search term(s). Should i be using document.referrer?
Please take a look at my code and tell me what i'm doing wrong: -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-
<html lang="en">
-
<head>
-
<title>highlight</title>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-
-
<script type="text/javascript">
-
function URL2Query()
-
{
-
var query = document.referrer("?","");
-
var Q = query.split("&");
-
var hash = {};
-
for(var i=Q.length-1;i>=0;--i)
-
{
-
var q = Q[i].split("=");
-
if(q[0]) hash[q[0]]=unescape(q[1]);
-
}
-
return hash;
-
}
-
-
window.onload=function(){
-
var queryString = URL2Query();
-
var contents=document.body.innerHTML;
-
var idx=contents.search(queryString.query);
-
if(idx!=-1) {
-
contents=contents.replace(queryString.query,'<span id="highlight">'+queryString.query+'</span>');
-
document.body.innerHTML=contents;
-
document.getElementById('highlight').scrollIntoView();
-
}
-
};
-
</script>
-
-
<style type="text/css">
-
#highlight {background:yellow;}
-
</style>
-
-
</head>
-
<body>
-
<script>
-
document.write(document.referrer);
-
</script>
-
-
<h1>Nirafo</h1>
-
<p>Aphasm escit ra apovum ecripsat. Quorepl alist osmephum ime itasmotis to eleh.
-
Quadeth est. Coticreus oce ro omuf ari trolodeus est. Nosm est. Thihopsiem,
-
minus beh brofiprue teranis. </p>
-
<h2>Smopada</h2>
-
<h2>Edrecram Ol <a href="highlight2.htm">Quorobucranis</a></h2>
-
<h3>Funap</h3>
-
<p>Ohusch ifemes, presn mapliant ple pupriem nalaho. Acrutra son cro teton hi
-
prenaquid est. Ocophiant asi pso bratetriem eta cragasch est. Volespes in
-
aplasnem usnerhant. Gerociant ina quidu tefum ag hiphue est. </p>
-
<p>Trog crin maquor on crebatuer tes efascranis. Ehisc pibisnam snatofas, ic
-
smot pel vavetont. Drup nicrus quido edesmiem plarodonis. Ugepsiant sosch log
-
fathon atahotis. Stim dabr quorimapseus vi dathat ufo lequadat. Quoreh muspeus
-
quidicusp, bro psopl tutist ropinuer. Schops tremorh, otusm lusagore dro
-
aquorospore pluvusmont. Socelum in rhetapa tumotis. Tof, vufucrue ul uquadicrum
-
ulovant. Smotr ruquidi ipreprant, an ugist popupr mucanis. Acron osmac ipeh vav
-
iloquader quadi govedas. Das mipacras, scet roteprore tin tabesch opod. Escreh
-
quadot dipapam nan hubo bre etomas. Sorhiant, vasta quoro opraquoriant
-
meriplotis. </p>
-
<p>Apoquid equoraphes mo buthi apretrotis. Fasm ohesmus, phud planerhes pe
-
mafothius itohonis. Brigiquorum in imischius vicrat. Smubr est. Orhan ipsev
-
tigigue ana omosmer ide tacront. </p>
-
<h3>Omorue</h3>
-
<p>Escol tosn umequidem vef asmibrer vi poricatis. Rothiem ef ano olotreus ah
-
stepephum est. Elicr osnepla baquadont, hes thisp osmicriant quidoteplant.
-
Ipricreus in falusmam esmobrat. Losch brebuquadum vi scasuquidam psenerer. Nasm
-
trunopsit ac regabue tobiscro. Scropl thabipiant at tequadore raciquidat.
-
Thatoscrus psinorat, staquad letore rhu dam moscuer. Gunit spisp to tahius
-
abribruer. Rhol brim asarus ahe epifer ega lononont. Stuph laspa ubi spimason
-
palanis. Rilebrue in alabon anabruer. Losm eda toh itrismeus schi rismus est.
-
Brov trotiphue eni ditob abrecras. </p>
-
<p>Scrapabrue in ololum ihaschotis. Uphar est. Soquid oquorephem hec stoniquadus
-
catasp. Anosc escruquad ip ihetha listonis. Mes in mirus uhiscanis. </p>
-
<h3>Pre Obaquad Nohequorant</h3>
-
<p>Thoph rutuphem, schin nobram ah ivascon psahitotis. Esmal quorabiteus ehi
-
dimequor cunavanis. Arhel odagus pse ospaquideus psotamont. Metoquidi pre ohe
-
vaquidam sce icimius est. Spast thesepus ime gafore apriquadatis. </p>
-
<h2>Rhenosmanis</h2>
-
<h3>Tah Conedit Drageschat</h3>
-
<p>Cril mepam spihecront, im psen scrumirham devath. Ciquid scar ladam thu
-
comanatis oro etrusmas. Thol diprem, uthuf piva ob phetepses craramatis. Epirh
-
est. Ohasc pufim im otagit matiphas. Osmod locuscam, ulerh givescam alo
-
ferespius familonis. Idabreus quorid ha phogemiem imeplont. Osith busnem
-
scrapinant, ta craf ethosn losmonis. Pofiem gi ilu lapemem eg opadrius est.
-
Breps snesascram, asath abuquadeus ho nophes vupodont. Quorideham, corap et
-
scriperem schohuto. Path tesothius noper, dru quadicr atradr ehapsant. Smes
-
uton, quidap scerosch tre pibiniant poher. </p>
-
-
</body>
-
</html>
2 2901
Heya, Celeste. Welcome to TSDN!
Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).
Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
- document.referrer("?","");
should use replace: - document.referrer.replace("?","");
What happens with your code? Do you get any errors?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: leegold2 |
last post by:
Commonly done, eg. you enter a word in a search engine and when a
hit-page comes up the search word(s) are highlighted.
I'm doing a fulltext search that works well but I've tried a few
"packaged...
|
by: Craig Cockburn |
last post by:
Hi
I'm aware of the use of robots.txt and the use of <META NAME="ROBOTS"
CONTENT="index,follow">
However, what would be more useful is to be able to control within a
page which elements of...
|
by: Daniel Di Vita |
last post by:
I have created an ASP.NET page that allows the user to page through a result
set. I need to expand on this. On that same page I a filed where the user can
type in a search string. When they click...
|
by: shapper |
last post by:
Hello,
I am creating a search engine which searches keywords inside SQL
database and displays the results in a web page.
In the results web page I would like to give a grey background to the...
|
by: emailus |
last post by:
I am webmaster for the domain <www.alpha1.org.au>.
Not being an expert in html, I take advantage of my domain
Registrant's web building tool, 'Instant Website'. This tool is
provided as part of...
|
by: tirath |
last post by:
hi,
I have a DataView which has around 50 items(the page has scrollbars).
there is a search box on top of the page. when user enters an Id, i do
DataView.find("Id"). I get the row index but i...
|
by: Merlin1857 |
last post by:
How to search multiple fields using ASP
A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and...
|
by: wmbrae |
last post by:
I trying to make a javascript document reader in 2 frames.
The left frame displays the document, the right frame shows a list of document links.
This is as far as I got
...
|
by: db007 |
last post by:
Hi,
I have a problem with a current project and the scroll position.
I have an AJAX enabled website using Visual Studio 2005 and ASP.Net 2.0.
The project also uses masterpages.
On the...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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,...
|
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...
|
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: 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,...
| |