iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Closed Thread
 
LinkBack Thread Tools
Old October 4th, 2007, 09:15 AM   #1
New Member
 

Join Date: Oct 2007
Location: uk
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 philsando is on a distinguished road
[SOLVED] Image script problem

The script is for displaying random images:

HTML Code:
<script language="JavaScript" type="text/javascript"><!--
thisPage = "home";
onload_hook = onLoadSetUp
function errHandl(a,b,c) {
    if (showErr) return false; 
    else return true;
}
//self.onerror = errHandl;
if (!document.images) {
    alert("Your browser does not support image\n" +
    "manipulation by JavaScript.  [Browser\n" +
    "software may be an obsolete version]\n" +
    "The slide show will not be visible.");
}
var slideTotal=54; advAfter=20000;
var showErr=false, sourceNo=0, targetNo=0; hotSlide=0;
var slidesNotStarted=true;
var targetMsg = new Array("message zero", "-", "-", "-", "-", "-", "-");
var targetAuth = new Array("author zero", "-", "-", "-", "-", "-", "-");
var targetTitl = new Array("title zero", "-", "-", "-", "-", "-", "-");
var sourceMsg = new Array("Scanning EM of parasite's cercarial stage [Prof Lewis, Ecol Evol Behav]", "Warbler: Acrocephalus arundinaceus [Prof Catchpole, Ecol Evol Behav]", "Cowpea weevil: Callosobruchus maculatus [Dr Credland, Ecol Evol Behav]", "Cercarial stage of fish liver fluke [Prof Lewis, Ecol Evol Behav]", "Recombinant dystrophin in mdx muscle [Prof Dickson, Biomed Sci]", "Cells in culture", "Arabidopsis thaliana", "Arabidopsis thaliana", "Embryos of amphipod: Gammarus duebeni [Dr Morritt, Ecol Evol Behav]", "Fluorescent protein targeting in stomatal cells [Dr Lopez-Juez, Plant Mol Sci]", "Skeletal muscle, target for gene therapy [Prof Dickson, Biomed Sci]", "Base of antenna: Callosobruchus maculatus [Dr Credland, Ecol Evol Behav]", "Sporulating Bacillus subtilis [Dr Cutting, Biomed Sci]", "Ovigerous beachflea: Orchestia gammarellus [Dr Morritt, Ecol Evol Behav]", "Lycopersicon esculentum: tomatoes with beta-carotene [Prof Bramley, Plant Mol Sci]", "Chromosome tangling checkpoint [Plant Mol Sci]", "Marine mollusc [Dr Morritt, Ecol Evol Behav]", "Dormouse: nocturnal forager [Dr Bright, Ecol Evol Behav]", "Daphnia: the water flea", "Fieldwork in undergraduate ecology course", "Hedgehog: nocturnal predator", "Petal epidermis: scanning EM [Dr Ford, Plant Mol Sci]", "Transmission electron micrograph [Dr Andrews, EM Unit]", "From undergraduate entomology course", "From undergraduate genetics course", "Acrocephalus schoenobaenus: female choice and DNA analysis of paternity [Prof Catchpole, Ecol Evol Behav]", "Brain neuron [Dr Empson, Biomed Sci]", "Entamoeba histolytica [Dr Tovar, Biomed Sci]", "Echinoderm: Asterias rubens [Ecol Evol Behav]", "Pelagic cichlid: Rhamphochromis brevis [Dr Shaw, Ecol Evol Behav]", "Cuttlefish: Sepia officinalis [Dr Shaw, Ecol Evol Behav]", "Adenoviral gene therapy vectors [Prof Dickson, Biomed Sci]", "Mormyrid fish: Gnathonemus [Prof Lewis, Ecol Evol Behav]", "Frost: mechanisms of plant tolerance", "Peroxidase enzyme structure [Prof Bolwell, Plant Mol Sci]", "Acrocephalus schoenobaenus: sonogram [Prof Catchpole, Ecol Evol Behav]", "Lycopene: antioxidant pigment of tomato [Prof Bramley, Plant Mol Sci]", "Computer model of adenoviral gene therapy vector  [Prof Dickson, Biomed Sci]", "Inspecting carotenoid production in tomatoes [Prof Bramley, Plant Mol Sci]", "Video microscopy in undergraduate practical", "Thermal monitoring of limpet in nature [Dr Morritt, Ecol Evol Behav]", "Stripes of gene expression in brain tissue [Dr Beesley, Biomed Sci]", "Synapses [Dr Beesley, Biomed Sci]", "Green fluorescent reporter protein in transfected neuron [Dr Beesley, Biomed Sci]", "Green fluorescent tagging of frost tolerance protein", "Microarray analysis of floral senescence [Dr Stead, Plant Mol Sci]", "Lipid globules in Blakeslea mycelium [Prof Bramley, Plant Mol Sci]", " ", " ", "BCOP [Prof Duden, Biomed Sci]", "Connexin [Prof Duden, Biomed Sci]", "COPI vesicle [Prof Duden, Biomed Sci]", "FRET [Prof Duden, Biomed Sci]", "Golgi [Prof Duden, Biomed Sci]");
var sourceAuth = new Array("Lewis", "Catchpole", "Credland", "Lewis", "Dickson", "-", "-", "-", "Morritt", "Lopez-Juez", "Dickson", "Credland", "Cutting", "Morritt", "Bramley", "Bogre", "Morritt", "Bright", "-", "-", "-", "Ford", "Andrews", "-", "-", "Catchpole", "Empson", "Tovar", "-", "Shaw", "Shaw", "Dickson", "Lewis", "Warren", "Bolwell", "Catchpole", "Bramley", "Dickson", "Bramley", "-", "Morritt", "Beesley", "Beesley", "Beesley", "-", "Stead", "Bramley", "-", "-", "Duden", "Duden", "Duden", "Duden", "Duden");
var sourceTitl = new Array("Prof.", "Prof.", "Dr.", "Prof.", "Prof.", "-", "-", "-", "Dr.", "Dr.", "Prof.", "Dr.", "Dr.", "Dr.", "Prof.", "Dr.", "Dr.", "Dr.", "-", "-", "-", "Dr.", "Dr.", "-", "-", "Prof.", "Dr.", "Dr.", "-", "Dr.", "Dr.", "Prof.", "Prof.", "-", "Prof.", "Prof.", "Prof.", "Prof.", "Prof.", "-", "Dr.", "Dr.", "Dr.", "Dr.", "Dr.", "Dr.", "Prof.", "-", "-", "Prof.", "Prof.", "Prof.", "Prof.", "Prof.");
// last one is currently, zp53.gif (54 in total)
    a = new Date(); 
    b = (a.getTime())/slideTotal;
    c = slideTotal*(b-Math.floor(b)+0.001); d = Math.floor(c);
    if (d>slideTotal) d=slideTotal; 
    sourceNo=d;
    // sourceNo can be from 0 to (initial slideTotal-1)
    slideTotal-=1;
    b = (a.getTime())/slideTotal;
    c = slideTotal*(b-Math.floor(b)+0.001); d = 1+Math.floor(c);
    if (d>slideTotal) d=slideTotal; 
    sourceAdv=d;
//     sourceAdv can be from 1 to (initial slideTotal-1)
//
    cW = new Date ();
    cW.setMonth(7);
// Jan=0, Dec=11
    cW.setDate(16);
//    if (a.getTime() > cW.getTime()) top.location = "indexclsp.html";
//
function loadNextSlide() {
    if (document.images) {
        sourceNo+=sourceAdv;
        if (sourceNo>slideTotal) sourceNo-=(slideTotal+1);
        targetNo+=1;
        if (targetNo>5) targetNo=1;
        sourceName = "_gifs/zp"+sourceNo+".gif";
        targetName="target"+targetNo;
        targetMsg[targetNo]=sourceMsg[sourceNo];
        targetAuth[targetNo]=sourceAuth[sourceNo];
        targetTitl[targetNo]=sourceTitl[sourceNo];
        swapIm(targetName,sourceName);
        window.status=" ";
    }
}
function slideTimer() {
    if (hotSlide>0) {
        setTimeout('slideTimer()',200);
        return;
    }
   loadNextSlide();
    slidesNotStarted=false;
    setTimeout('slideTimer()',advAfter);
}
//
function initialSlideLoad() {
    for (i=0;i<5;i++) {
        loadNextSlide();
    }
}
//
function swapIm(targetName,sourceName) {
    if (document.images) {
        document.images[targetName].src = sourceName;
}    }
//
function showSlideInfo(pointedAt) {
    hotSlide=pointedAt;
    window.status=targetMsg[hotSlide];
    selAuth=targetAuth[pointedAt];
}
//
function linkQuery(pointedAt) {
    selAuth=targetTitl[pointedAt]+" "+targetAuth[pointedAt];
    msg="Do you want to go to the web page describing research"+
        "  by "+selAuth+", from which the selected photograph"+
         "  is taken?  (The page will open in a new window.)";
    if (selAuth.length>5) {
        if (confirm(msg)) {
            top.location="AcademicStaff/"+targetAuth[pointedAt]; } }
}
//
function onLoadSetUp() {
initialSlideLoad();
setTimeout('slideTimer()',15000);
}
//
var jsversion = 1.0
// --></SCRIPT>

Then on the body tag there is a call to:

HTML Code:
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" 
      onLoad="
     function blockError (){return true};
     window.onerror = blockError;
     grey_out(thisPage); 
     if (onload_hook) {onload_hook ()}"
>
In the page I am developing I have no access to the <body> tag, so cannot enter this code due to it being locked by the template system.

Does anyone know of a way I can get this script to work without adding the code to the body tag?

Any help appreciated

Thanks a lot

Last edited by Rakuli; October 4th, 2007 at 09:34 AM.. Reason: Please use [html] bbc tags when posting code
philsando is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 4th, 2007, 09:41 AM   #2
Highly Reputable Member
SuperMember
 
Rakuli's Avatar
 

Join Date: Sep 2007
Location: Australia
Age: 25
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold
Re: Image script problem

Hi philsando, welcome to Webforumz


If I can just clarify..

You want to have something happen onload of the page?

You don't need access to the <body> tag for that you can use

Code:
function blockError() {return true;}
window.onerror = blockError;

window.onload = function () 
{ 
    grey_out (thisPage); 
    if (onload_hook) 
    onload_hook();
};
You can add that to your main script. Is this what you mean?

Cheers,
__________________
Luke Dingle . com
Rakuli is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 4th, 2007, 09:47 AM   #3
New Member
 

Join Date: Oct 2007
Location: uk
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 philsando is on a distinguished road
Re: Image script problem

Yep I basically want the script to work as normal, without needing to access the body tag.

Thanks for the reply, where about would I insert that code?

Thanks
philsando is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 4th, 2007, 09:50 AM   #4
Highly Reputable Member
SuperMember
 
Rakuli's Avatar
 

Join Date: Sep 2007
Location: Australia
Age: 25
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold
Re: Image script problem

place that as the very first thing in your script.

So if your main script is in the <head>tag, place it right underneath the <script> tag.

Cheers,
__________________
Luke Dingle . com
Rakuli is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 4th, 2007, 09:56 AM   #5
New Member
 

Join Date: Oct 2007
Location: uk
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 philsando is on a distinguished road
Re: Image script problem

So now I have:

HTML Code:
<script language="JavaScript" type="text/javascript">
[b] <!--
function blockError() {return true;}
window.onerror = blockError;

window.onload = function () 
{ 
    grey_out (thisPage); 
    if (onload_hook) 
    onload_hook();
};[/b] 
thisPage = "home";
onload_hook = onLoadSetUp
function errHandl(a,b,c) {
    if (showErr) return false; 
    else return true;
}
//self.onerror = errHandl;
if (!document.images) {
    alert("Your browser does not support image\n" +
    "manipulation by JavaScript.  [Browser\n" +
    "software may be an obsolete version]\n" +
    "The slide show will not be visible.");
}
var slideTotal=54; advAfter=20000;
var showErr=false, sourceNo=0, targetNo=0; hotSlide=0;
var slidesNotStarted=true;
var targetMsg = new Array("message zero", "-", "-", "-", "-", "-", "-");
var targetAuth = new Array("author zero", "-", "-", "-", "-", "-", "-");
var targetTitl = new Array("title zero", "-", "-", "-", "-", "-", "-");
var sourceMsg = new Array("Scanning EM of parasite's cercarial stage [Prof Lewis, Ecol Evol Behav]", "Warbler: Acrocephalus arundinaceus [Prof Catchpole, Ecol Evol Behav]", "Cowpea weevil: Callosobruchus maculatus [Dr Credland, Ecol Evol Behav]", "Cercarial stage of fish liver fluke [Prof Lewis, Ecol Evol Behav]", "Recombinant dystrophin in mdx muscle [Prof Dickson, Biomed Sci]", "Cells in culture", "Arabidopsis thaliana", "Arabidopsis thaliana", "Embryos of amphipod: Gammarus duebeni [Dr Morritt, Ecol Evol Behav]", "Fluorescent protein targeting in stomatal cells [Dr Lopez-Juez, Plant Mol Sci]", "Skeletal muscle, target for gene therapy [Prof Dickson, Biomed Sci]", "Base of antenna: Callosobruchus maculatus [Dr Credland, Ecol Evol Behav]", "Sporulating Bacillus subtilis [Dr Cutting, Biomed Sci]", "Ovigerous beachflea: Orchestia gammarellus [Dr Morritt, Ecol Evol Behav]", "Lycopersicon esculentum: tomatoes with beta-carotene [Prof Bramley, Plant Mol Sci]", "Chromosome tangling checkpoint [Plant Mol Sci]", "Marine mollusc [Dr Morritt, Ecol Evol Behav]", "Dormouse: nocturnal forager [Dr Bright, Ecol Evol Behav]", "Daphnia: the water flea", "Fieldwork in undergraduate ecology course", "Hedgehog: nocturnal predator", "Petal epidermis: scanning EM [Dr Ford, Plant Mol Sci]", "Transmission electron micrograph [Dr Andrews, EM Unit]", "From undergraduate entomology course", "From undergraduate genetics course", "Acrocephalus schoenobaenus: female choice and DNA analysis of paternity [Prof Catchpole, Ecol Evol Behav]", "Brain neuron [Dr Empson, Biomed Sci]", "Entamoeba histolytica [Dr Tovar, Biomed Sci]", "Echinoderm: Asterias rubens [Ecol Evol Behav]", "Pelagic cichlid: Rhamphochromis brevis [Dr Shaw, Ecol Evol Behav]", "Cuttlefish: Sepia officinalis [Dr Shaw, Ecol Evol Behav]", "Adenoviral gene therapy vectors [Prof Dickson, Biomed Sci]", "Mormyrid fish: Gnathonemus [Prof Lewis, Ecol Evol Behav]", "Frost: mechanisms of plant tolerance", "Peroxidase enzyme structure [Prof Bolwell, Plant Mol Sci]", "Acrocephalus schoenobaenus: sonogram [Prof Catchpole, Ecol Evol Behav]", "Lycopene: antioxidant pigment of tomato [Prof Bramley, Plant Mol Sci]", "Computer model of adenoviral gene therapy vector  [Prof Dickson, Biomed Sci]", "Inspecting carotenoid production in tomatoes [Prof Bramley, Plant Mol Sci]", "Video microscopy in undergraduate practical", "Thermal monitoring of limpet in nature [Dr Morritt, Ecol Evol Behav]", "Stripes of gene expression in brain tissue [Dr Beesley, Biomed Sci]", "Synapses [Dr Beesley, Biomed Sci]", "Green fluorescent reporter protein in transfected neuron [Dr Beesley, Biomed Sci]", "Green fluorescent tagging of frost tolerance protein", "Microarray analysis of floral senescence [Dr Stead, Plant Mol Sci]", "Lipid globules in Blakeslea mycelium [Prof Bramley, Plant Mol Sci]", " ", " ", "BCOP [Prof Duden, Biomed Sci]", "Connexin [Prof Duden, Biomed Sci]", "COPI vesicle [Prof Duden, Biomed Sci]", "FRET [Prof Duden, Biomed Sci]", "Golgi [Prof Duden, Biomed Sci]");
var sourceAuth = new Array("Lewis", "Catchpole", "Credland", "Lewis", "Dickson", "-", "-", "-", "Morritt", "Lopez-Juez", "Dickson", "Credland", "Cutting", "Morritt", "Bramley", "Bogre", "Morritt", "Bright", "-", "-", "-", "Ford", "Andrews", "-", "-", "Catchpole", "Empson", "Tovar", "-", "Shaw", "Shaw", "Dickson", "Lewis", "Warren", "Bolwell", "Catchpole", "Bramley", "Dickson", "Bramley", "-", "Morritt", "Beesley", "Beesley", "Beesley", "-", "Stead", "Bramley", "-", "-", "Duden", "Duden", "Duden", "Duden", "Duden");
var sourceTitl = new Array("Prof.", "Prof.", "Dr.", "Prof.", "Prof.", "-", "-", "-", "Dr.", "Dr.", "Prof.", "Dr.", "Dr.", "Dr.", "Prof.", "Dr.", "Dr.", "Dr.", "-", "-", "-", "Dr.", "Dr.", "-", "-", "Prof.", "Dr.", "Dr.", "-", "Dr.", "Dr.", "Prof.", "Prof.", "-", "Prof.", "Prof.", "Prof.", "Prof.", "Prof.", "-", "Dr.", "Dr.", "Dr.", "Dr.", "Dr.", "Dr.", "Prof.", "-", "-", "Prof.", "Prof.", "Prof.", "Prof.", "Prof.");
// last one is currently, zp53.gif (54 in total)
    a = new Date(); 
    b = (a.getTime())/slideTotal;
    c = slideTotal*(b-Math.floor(b)+0.001); d = Math.floor(c);
    if (d>slideTotal) d=slideTotal; 
    sourceNo=d;
    // sourceNo can be from 0 to (initial slideTotal-1)
    slideTotal-=1;
    b = (a.getTime())/slideTotal;
    c = slideTotal*(b-Math.floor(b)+0.001); d = 1+Math.floor(c);
    if (d>slideTotal) d=slideTotal; 
    sourceAdv=d;
//     sourceAdv can be from 1 to (initial slideTotal-1)
//
    cW = new Date ();
    cW.setMonth(7);
// Jan=0, Dec=11
    cW.setDate(16);
//    if (a.getTime() > cW.getTime()) top.location = "indexclsp.html";
//
function loadNextSlide() {
    if (document.images) {
        sourceNo+=sourceAdv;
        if (sourceNo>slideTotal) sourceNo-=(slideTotal+1);
        targetNo+=1;
        if (targetNo>5) targetNo=1;
        sourceName = "_gifs/zp"+sourceNo+".gif";
        targetName="target"+targetNo;
        targetMsg[targetNo]=sourceMsg[sourceNo];
        targetAuth[targetNo]=sourceAuth[sourceNo];
        targetTitl[targetNo]=sourceTitl[sourceNo];
        swapIm(targetName,sourceName);
        window.status=" ";
    }
}
function slideTimer() {
    if (hotSlide>0) {
        setTimeout('slideTimer()',200);
        return;
    }
   loadNextSlide();
    slidesNotStarted=false;
    setTimeout('slideTimer()',advAfter);
}
//
function initialSlideLoad() {
    for (i=0;i<5;i++) {
        loadNextSlide();
    }
}
//
function swapIm(targetName,sourceName) {
    if (document.images) {
        document.images[targetName].src = sourceName;
}    }
//
function showSlideInfo(pointedAt) {
    hotSlide=pointedAt;
    window.status=targetMsg[hotSlide];
    selAuth=targetAuth[pointedAt];
}
//
function linkQuery(pointedAt) {
    selAuth=targetTitl[pointedAt]+" "+targetAuth[pointedAt];
    msg="Do you want to go to the web page describing research"+
        "  by "+selAuth+", from which the selected photograph"+
         "  is taken?  (The page will open in a new window.)";
    if (selAuth.length>5) {
        if (confirm(msg)) {
            top.location="AcademicStaff/"+targetAuth[pointedAt]; } }
}
//
function onLoadSetUp() {
initialSlideLoad();
setTimeout('slideTimer()',15000);
}
//
var jsversion = 1.0
// --></SCRIPT>
Is that correct? It doesnt seem to have made a difference.

Thanks again

Last edited by Rakuli; October 4th, 2007 at 10:04 AM.. Reason: changed [code] to [html] as it is very hard to read.
philsando is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 4th, 2007, 10:58 AM   #6
New Member
 

Join Date: Oct 2007
Location: uk
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 philsando is on a distinguished road
Re: Image script problem

This thread can be closed. Problem now solved thanks
philsando is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] foreach problem -- table of contents script MikeHopley PHP 1 April 4th, 2008 08:51 AM
[SOLVED] Image Upload Problem kidreapertronV PHP 1 January 31st, 2008 03:38 PM
[SOLVED] Image UPDATE problem kidreapertronV PHP 2 January 31st, 2008 03:38 PM
[SOLVED] div background image problem in ie Rincewind HTML, XHTML and CSS 7 November 30th, 2007 06:30 AM
[SOLVED] Php/Mysql Image Problem longstand PHP 6 October 17th, 2007 02:27 PM


Search Engine Optimization by vBSEO 3.2.0 RC8