Resend my activation email : Register : Log in 
BCF: Bike Chat Forums


Javascript problem PLEASE HELP

Reply to topic
Bike Chat Forums Index -> The Geek Zone
View previous topic : View next topic  
Author Message

andrew
Mister Road Rage



Joined: 03 Feb 2002
Karma :

PostPosted: 17:36 - 19 Apr 2007    Post subject: Javascript problem PLEASE HELP Reply with quote

I am really stuck and would really apreciate some help. I've been given the task of making a flat webpage for a client at work, the problem i'm having is they want some ads on the site and have supplied ad tags in Javascript. Unfortunatley i've never touched javascript. I'm guessing the random number generator goes into the head of the code but where do i put the other parts of the code? I've made a <div> that will hold the banner, will the remaining code sit in there?

The code is below....

*** Code ***
RANDOM NUMBER GENERATOR - Use only once per page between the head commands

<script language="Javascript">
<!--
var axel = Math.random() + "";
var ord = axel * 1000000000000000000;
//-->
</script>

************************************************** *
a.pop.tmus/achemy-skyscraper 160x600
************************************************** *
<SCRIPT LANGUAGE="JavaScript">
document.write('<SCR'+'IPT LANGUAGE="JavaScript1.1" SRC="a_rather_long_url;tile=1;dcopt=ist;sz=160x600;ord= ' + ord + '?" ><\/SCRIPT>');
</SCRIPT>
<SCRIPT>
if ((!document.images && navigator.userAgent.indexOf("Mozilla/2.") >= 0) || navigator.userAgent.indexOf("WebTV")>= 0) {
document.write('<A HREF="a_rather_long_url;tile=1;sz=160x600;ord=' + ord + '?" TARGET="_blank">');
document.write('<IMG SRC="a_rather_long_url;tile=1;sz=160x600;ord=' + ord + '?" WIDTH="160" HEIGHT="600" BORDER="0" ALT=""></A>');
}
</SCRIPT>
<NOSCRIPT>
<A HREF="a_rather_long_url;tile=1;sz=160x600;ord=123456789? " TARGET="_blank">
<IMG SRC="a_rather_long_url;tile=1;sz=160x600;ord=123456789? " WIDTH="160" HEIGHT="600" BORDER="0" ALT=""></A>
</NOSCRIPT>
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Dom
World Chat Champion



Joined: 06 Sep 2004
Karma :

PostPosted: 17:59 - 19 Apr 2007    Post subject: Reply with quote

The other part of the code appears to be what prints out the banner/ad itself, so you'd be right.
____________________
Photos and that
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

bob-a-job
Scooby Slapper



Joined: 12 Apr 2006
Karma :

PostPosted: 18:02 - 19 Apr 2007    Post subject: Reply with quote

Dom wrote:
The other part of the code appears to be what prints out the banner/ad itself, so you'd be right.


Indeed - I concur!
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

andrew
Mister Road Rage



Joined: 03 Feb 2002
Karma :

PostPosted: 19:33 - 19 Apr 2007    Post subject: Reply with quote

The thing is, when i insert the code into the banner <div> it isn't a clickable link when it should be. If i place all the code between the <script> tags into the head and the <noscript> bit of the code into the div, and remove the <noscript> tags then it is clickable. Surely the company who gave me the code wouldn't be giving out code that would need to be edited like this.

Any ideas?
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Dom
World Chat Champion



Joined: 06 Sep 2004
Karma :

PostPosted: 21:05 - 19 Apr 2007    Post subject: Reply with quote

Firstly you shouldn't need a containing div, so you might as well ditch that to be sure it's not the problem.

Secondly if your removing the noscript tag 'fixes' it then is there a chance it's an odd behaviour from your own browser? (Have you tested in several?)

As you say, auto-generated code directly from the ad company should be perfect, so it's certainly strange. Though in truth that ad code does look a bit of a mess, quite why they need to go generating random numbers I've no idea.
____________________
Photos and that
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

andrew
Mister Road Rage



Joined: 03 Feb 2002
Karma :

PostPosted: 21:21 - 19 Apr 2007    Post subject: Reply with quote

Well it's going into a <div> so that i can posistion the banner. Someone else told me the code was a mess but wouldn't tell me why so i'm a bit stuck to be honest.

Could the number generator change the banner depending on what nubmer is generated when the javascript is loaded?
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Dom
World Chat Champion



Joined: 06 Sep 2004
Karma :

PostPosted: 08:48 - 20 Apr 2007    Post subject: Reply with quote

That appears to be what it's doing. The variable's called 'ord' and they've got it peppered around all over the place.

Tbh you may be best of asking this at a more techy forum. Although I implement a fair bit of JS I don't write much and tbh I'm not sure what the problem is here.

As a rule noscript content should only appear where scripting is disabled, so for it to effect what's going on when scripting's enabled is very weird.

Try Sitepoint.com/forums.
____________________
Photos and that
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

TheShaggyDA
Repost Police



Joined: 14 Jun 2004
Karma :

PostPosted: 09:57 - 20 Apr 2007    Post subject: Reply with quote

The random number is being used to generate a unique url, so that it will always fetch the banner rather than attempt to use a cached copy.

In the NOSCRIPT area, it's just hardcoded to "123456789?", so they won't get as many hits from that.
____________________
Current: CB500 Previous: CB100N, CB250RS, XJ900F, GT550, GPZ750R/1000RX, AJS M16, R100RT, Enfield Bullet

[i:6e3bfc7581]But still I fear and still I dare not laugh at the madman...[/i:6e3bfc7581]
 Back to top
View user's profile Send private message Visit poster's website You must be logged in to rate posts

Kickstart
The Oracle



Joined: 04 Feb 2002
Karma :

PostPosted: 10:54 - 20 Apr 2007    Post subject: Reply with quote

Andrew wrote:
Well it's going into a <div> so that i can posistion the banner. Someone else told me the code was a mess but wouldn't tell me why so i'm a bit stuck to be honest.


Can you try lobbing it between SPAN tags instead?

All the best

Keith
____________________
Traxpics, track day and racing photographs - Bimota Forum - Bike performance / thrust graphs for choosing gearing
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

andrew
Mister Road Rage



Joined: 03 Feb 2002
Karma :

PostPosted: 12:25 - 20 Apr 2007    Post subject: Reply with quote

Kickstart wrote:

Can you try lobbing it between SPAN tags instead?

All the best

Keith


I've tried that but the ad still isn't displaying...i've attached the entire page code below. Embarassed

<HTML>
<HEAD>
<Link rel="stylesheet" type="text/css" href="stylesheet.css">
<TITLE>Blah</TITLE>
<script language="Javascript">
<!--
var axel = Math.random() + "";
var ord = axel * 1000000000000000000;
//-->
</script>

<SCRIPT LANGUAGE="JavaScript">
document.write('<SCR'+'IPT LANGUAGE="JavaScript1.1" SRC="a rather long url;dcopt=ist;sz=160x600;ord=' + ord + '?" ><\/SCRIPT>');
</SCRIPT>

</HEAD>


<BODY>

<?php include "common_elements.html"; ?>

<div class="home_holder"><?php include "home_links.html"; ?></div>
<span class="skyscraper">
<SCRIPT>
if ((!document.images && navigator.userAgent.indexOf("Mozilla/2.") >= 0) || navigator.userAgent.indexOf("WebTV")>= 0) {
document.write('<A HREF="a rather long url;tile=1;sz=160x600;ord=' + ord + '?" TARGET="_blank">');
document.write('<IMG SRC="a rather long url;tile=1;sz=160x600;ord=' + ord + '?" WIDTH="160" HEIGHT="600" BORDER="0" ALT=""></A>');
}
</SCRIPT>
<NOSCRIPT>
<A HREF="a rather long url;tile=1;sz=160x600;ord=123456789?" TARGET="_blank">
<IMG SRC="a rather long url;tile=1;sz=160x600;ord=123456789?" WIDTH="160" HEIGHT="600" BORDER="0" ALT=""></A>
</NOSCRIPT>
</span>






<div class="banner">This is where the banner sits</div>

</BODY>
</HTML>
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Dom
World Chat Champion



Joined: 06 Sep 2004
Karma :

PostPosted: 12:29 - 20 Apr 2007    Post subject: Reply with quote

To be 100% sure, you have only submit the URL with 'a rather long url' for the sake of BCF right?

Can you just post the full URLs so we can test it?
____________________
Photos and that
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

andrew
Mister Road Rage



Joined: 03 Feb 2002
Karma :

PostPosted: 12:52 - 20 Apr 2007    Post subject: Reply with quote

Dom wrote:
To be 100% sure, you have only submit the URL with 'a rather long url' for the sake of BCF right?

Can you just post the full URLs so we can test it?


Yes, would you mind if i pm'd you the actual urls?

I hope it's not something i'm doing wrong, i feel like a bit of an idiot. Very Happy
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Kickstart
The Oracle



Joined: 04 Feb 2002
Karma :

PostPosted: 12:56 - 20 Apr 2007    Post subject: Reply with quote

Hi

Can you PM them to me as well.

All the best

Keith
____________________
Traxpics, track day and racing photographs - Bimota Forum - Bike performance / thrust graphs for choosing gearing
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

andrew
Mister Road Rage



Joined: 03 Feb 2002
Karma :

PostPosted: 13:07 - 20 Apr 2007    Post subject: Reply with quote

Done.
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Kickstart
The Oracle



Joined: 04 Feb 2002
Karma :

PostPosted: 13:33 - 20 Apr 2007    Post subject: Reply with quote

Hi

The if statement where it decides whether to put out the link does not equate to true on my machine, the displays are not executed.

All the best

Keith
____________________
Traxpics, track day and racing photographs - Bimota Forum - Bike performance / thrust graphs for choosing gearing
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

andrew
Mister Road Rage



Joined: 03 Feb 2002
Karma :

PostPosted: 13:43 - 20 Apr 2007    Post subject: Reply with quote

So what that code is doing is not displaying the ad codes because the user agent isn't mozilla??
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Kickstart
The Oracle



Joined: 04 Feb 2002
Karma :

PostPosted: 13:49 - 20 Apr 2007    Post subject: Reply with quote

Hi

For me "navigator.userAgent.indexOf("Mozilla/2.")" returns -1 (navigator.useragent is "Opera/9.01 (Windows NT 5.1; U; en)"), so basically I think what it is checking for is a bit screwy.

All the best

Keith
____________________
Traxpics, track day and racing photographs - Bimota Forum - Bike performance / thrust graphs for choosing gearing
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts
Old Thread Alert!

The last post was made 19 years, 187 days ago. Instead of replying here, would creating a new thread be more useful?
  Display posts from previous:   
This page may contain affiliate links, which means we may earn a small commission if a visitor clicks through and makes a purchase. By clicking on an affiliate link, you accept that third-party cookies will be set.

Post new topic   Reply to topic    Bike Chat Forums Index -> The Geek Zone All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Read the Terms of Use! - Powered by phpBB © phpBB Group
 

Debug Mode: ON - Server: birks (www) - Page Generation Time: 0.10 Sec - Server Load: 0.44 - MySQL Queries: 13 - Page Size: 97.67 Kb