Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP! why doesn't this script work?????

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
the image i want to appear works no problem from the first document referrer, but not the second one... any ideas?


if (document.referrer == " {

document.write(&quot;<a href=' src='backto.gif'></a>&quot;);




} // End--><SCRIPT LANGUAGE=&quot;JavaScript&quot;>



if (document.referrer == &quot; &quot;) {

document.write(&quot;< '><img src='backto.gif'></a>&quot;);




} // End --> </SCRIPT>
 
i'm afraid that one didn't work either - like before, when i visit the page from the first referring document, the image loads, but not the second one... any other thoughts?
 
You can try:


document.open();
document.write(&quot;....&quot;);
document.close();

This may allow you to open the document again to write to it.
 
Judging by what I read in the initial posting I think I spotted a couple of critical typos. So I came up with this revised version that I suggest that you try:

<script language=&quot;Javascript&quot;>

var DocRef = document.referrer;

var rGlbl = &quot;
var iGlbl = &quot;backto.gif&quot;;

var rLocl = &quot; &quot;;

var iLocl = &quot;backto.gif&quot;;

// next line is commented out, but could be uncommented for debugging purposes
// alert( &quot;DocRef=[&quot;+DocRef+&quot;],\rrGlbl=[&quot;+rGlbl+&quot;],\riGlbl=[&quot;+iGlbl+&quot;],\rrLocl=[&quot;+rLocl+&quot;],\riLocl=[&quot;+iLocl+&quot;].&quot; );


if ( DocRef == rGLbl )
{
document.write(&quot;<a href='&quot; + rGlbl + &quot;'><img src='&quot; + iGlbl + &quot;'></a>&quot;);

}
else if ( DocRef == rLocl )
{
document.write(&quot;<a href='&quot; + rLocl + &quot;'><img src='&quot; + iLocl + &quot;'></a>&quot;);
}
// End --> </SCRIPT>

Hope this helps,
PeterKV
 
Here is a quick follow-on to my previous reply.

The line that begins [var rGlbl =] ends with two semicolons [.cfm&quot;;;] where instead it should end with the usual one [.cfm&quot;;].

I spotted the ;; typo while reviewing my response in the preview window before submitting it.

But, it didn't show up when I went back to edit it.

So, I submitted anyways. Then, when I read the thread again - just in case - there it was. Strange.

PeterKV
 
i'm afraid none of these suggestions have done the trick - i appreciate the efforts though...
 
Suggestion:

Remove the comment from the alert line in my sample and run the web page executing it one more time to see if the DocREf value (stuff between the [] next to DocRef=, <g>) is _EXACTLY_ the same as the value for rLocl.

Why? Because the stuff after the question mark in rLocl url may not be included in the DocRef, it is query string text not stricly part of a url ... it varies you see <g>.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top