p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript (http://p2p.wrox.com/forumdisplay.php?f=85)
-   -   how two scripts run at a time ? (http://p2p.wrox.com/showthread.php?t=7231)

mateenmohd December 14th, 2003 03:29 AM

how two scripts run at a time ?
 
How can run two scripts at a time ?
I use following two scripts coding, but boths script not run at a time. One script run, other script not run why ?


<html>
<HEAD>
</HEAD>
<BODY>

<script language="JavaScript">
var text="TRIP Projects Under Contruction";
var textfont="arial";
var textcolor="0000ff";
var textstyle="italic";
var textsize="24";
var speed="2";
var posx="400";
var posy="160";
var scrollwidth="400";
var scrollheight="75";
var regkey="";
</script>
<script src="wheelscroll.js">

<script language="javascript">
var transition="23";
var posx="350";
var posy="200";
var image1="pic1.jpg";
var image2="pic2.jpg";
var image3="pic3.jpg";
var image4="pic4.jpg";
var image5="pic5.jpg";
var image6="pic6.jpg";
var speed="1"
var pause="1";
          </script>
          <script src="Reveal.js"</script>

<CENTER>
</BODY>
</html>

please help

Mateen

joefawcett December 14th, 2003 08:52 AM

Because you haven't closed the wheelscroll script tag.

--

Joe

stalker December 22nd, 2003 01:07 AM

nor the REVEAL script first tag


antisprite April 23rd, 2004 02:39 AM

PLEASE HELP!! :)

I also am having problems with the two script thing, I can't figure out what I have done wrong. Can anyone please point me in the right direction? I want to add a third script, ie. a dhtml menu but can't if I can't solve it. I think it's with the slideshow but I can't see it.

Luke



<html>
<head>
<title>Luke Ballard</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


<script language="JavaScript">
<!--

function SymError()
{
  return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
  return (new Object());
}

window.open = SymWinOpen;

//-->
</script>

<script language="JavaScript" type="text/javascript" src="js/roll.js"></script>
<script language="JavaScript1.2">

function reapply(){
setTimeout("slideit()",2000)
return true
}
window.onerror=reapply
</script>
<script language="JavaScript1.1">
<!--
var image1=new Image()
image1.src="img/slide1.gif"
var image2=new Image()
image2.src="img/slide2.gif"
var image3=new Image()
image3.src="img/slide3.gif"
//-->
</script>
<script language="javascript" src="roll.js"></script>
<script>
<!--
////change number of images below
var number_of_images=3
//change speed below (in seconds)
var speed=3
var step=1
var whichimage=1
function slideit(){
if (!document.images)
return
if (document.all)
slide.filters.blendTrans.apply()
document.images.slide.src=eval("image"+step+".src" )
if (document.all)
slide.filters.blendTrans.play()
whichimage=step
if (step<number_of_images)
step++
else
step=1
if (document.all)
setTimeout("slideit()",speed*1000+3000)
else
setTimeout("slideit()",speed*1000)
}
function slidelink(){
if (whichimage==1)
window.location="#"
else if (whichimage==2)
window.location="#"
else if (whichimage==3)
window.location="#"
}
//-->
</script>
<script>function changeScreenSize(w,h){window.resizeTo( w,h )}</script>
<link rel="STYLESHEET" type="text/css" href="fonts.css">

</head>


ChrisScott April 23rd, 2004 05:20 AM

Hi Luke,

Can you post the content of your roll.js file & body tag?

Thanks,

Chris


antisprite April 23rd, 2004 07:53 AM

/js/roll.js

<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->


- BODY TAG -

<body background="img/home_bg2.gif" onload="changeScreenSize(800,600)" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0" onLoad="var SymTmpWinOpen = window.open; window.open = SymWinOpen; var SymTmpWinOpen = window.open; window.open = SymWinOpen; MM_preloadImages('img/home_nav_home_over.gif','img/home_nav_about_us_over.gif','img/home_nav_contact_us_over.gif','img/home_nav_selling_over.gif','img/home_nav_buying_over.gif',preload(),slideit(); window.open = SymTmpWinOpen;; window.open = SymTmpWinOpen;">



ChrisScott April 23rd, 2004 10:37 AM

Hi Luke,

A few things...

- you only need to reference the roll.js file once (there are two script tags linking to it)
- the body tag should only have one onload attribute
- your second onload attribute contains the following...

var SymTmpWinOpen = window.open;
window.open = SymWinOpen;
var SymTmpWinOpen = window.open;
window.open = SymWinOpen;
MM_preloadImages('img/home_nav_home_over.gif','img/home_nav_about_us_over.gif','img/home_nav_contact_us_over.gif','img/home_nav_selling_over.gif','img/home_nav_buying_over.gif',preload(),slideit();
window.open = SymTmpWinOpen;;
window.open = SymTmpWinOpen;

I'm not sure what you're trying to do with the SymTmpWinOpen = window.open and window.open = SymTmpWinOpen lines, but the preload images one should surely be something like...

MM_preloadImages('img/home_nav_home_over.gif','img/home_nav_about_us_over.gif','img/home_nav_contact_us_over.gif','img/home_nav_selling_over.gif','img/home_nav_buying_over.gif');

preload();
slideit();

If this is the case, there is no preload() function defined in your code & this will throw an error.

I think it would make it easier to move this code to a function and call that function from your onload tag.

Best regards,

Chris



antisprite April 23rd, 2004 06:50 PM

Hey again,

Thanks for your help so far. Here is my dilemma, I really hope you can help me sort it out. I have two things I want to achieve with index.html on this site, the first is a slideshow of photos from the local area (I am a realtor and it is a sales website :)) and the second is ... well ... I made the decision that I was designing for 800x600 as many of my clientele have older computers and would get confused by a high end website with lots of scrolling and while it doesn't matter if other pages in the site are viewed at 1024x768, index.html looks crap if viewed at another res other than 800x600 due to the background and graphics layout.

The stupid thing is I am really attached to the background viniette as it basically comes down to corporate colours so I don't want to change that. I know I am being difficult.

So ... I inserted what I thought was suitable code to resize index.html at 800x600 and it works initially but if the user views another window on their screen and then switches back to my site, the site maximises with complete disregard for my code.

And while the code is in place for resizing, the slideshow doesn't work. :( If someone can help me get both elements working at the same time AND get resizing working properly so my index.html works forever in 800x600 without changing (even if there is a way to lock the maximise button and not give viewers the resize option manually) I will be forever grateful.

I have included my entire index.html code, roll.js is included above.

Regards,

Luke
luke@lukeballard.com

<html>
<head>
<title>Luke Ballard</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



<script language="JavaScript">
<!--

function SymError()
{
  return true;
}

window.onerror = SymError;

//-->
</script>

<script language="JavaScript">
<!--

function SymError()
{
  return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
  return (new Object());
}

window.open = SymWinOpen;

//-->
</script>
<script language="JavaScript1.2">

function reapply(){
setTimeout("slideit()",2000)
return true
}
window.onerror=reapply
</script>
<script language="JavaScript1.1">
<!--
var image1=new Image()
image1.src="img/slide2.gif"
var Image2=new Image()
image2.src="img/slide1.gif"
var Image3=new Image()
image3.src="img/slide3.gif"
//-->
</script>
<script language="javascript" src="roll.js"></script>
<script>
<!--
////change number of images below
var number_of_images=3
//change speed below (in seconds)
var speed=3
var step=1
var whichimage=1
function slideit(){
if (!document.images)
return
if (document.all)
slide.filters.blendTrans.apply()
document.images.slide.src=eval("image"+step+".src" )
if (document.all)
slide.filters.blendTrans.play()
whichimage=step
if (step<number_of_images)
step++
else
step=1
if (document.all)
setTimeout("slideit()",speed*1000+3000)
else
setTimeout("slideit()",speed*1000)
}
function slidelink(){
if (whichimage==1)
window.location="#"
else if (whichimage==2)
window.location="#"
else if (whichimage==3)
window.location="#"
}
//-->
</script>
<link rel="STYLESHEET" type="text/css" href="fonts.css">
<script>function changeScreenSize(w,h){window.resizeTo( w,h )}</script>
</head>
<body background="img/home_bg2.gif" onload="changeScreenSize(800,600)">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
    <td>

    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td>





        </td>
        <td width="100%">

        <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td align="right"><img src="img/homeright.gif" width="350" height="119" alt="" border="0"></td>
        </tr>

        </table>


        </td>
    </tr>
    </table>

    </td>
</tr>
<tr>
    <td>

    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr><td align="left"><IMG SRC="img/buttons.gif" USEMAP="#buttons" BORDER=1 width="163" height="280" usemap="#icons"></td>

        <td width="594"><a href="javascript:slidelink()" onMouseover="window.status='Views from beautiful Caloundra.';return true" onMouseout="window.status=''"><img src="img/slide2.gif" height="282" width="594" name="slide" border=1 style="filter:blendTrans(duration=3)"></td>
        </tr>
    </table>

    </td>
</tr>
<tr>
    <td>

    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td width="369"><img src="img/home_footer_left.gif" width="369" height="17"></td>
        <td width="100%" background="img/home_footer_end.gif"><img src="img/home_footer_right.gif" width="391" height="17"></td>
    </tr>
    </table>

    </td>
</tr>


</body>

<script language="JavaScript">
<!--

window.open = SymRealWinOpen;

//-->
</script>

</html>


<MAP NAME="buttons">
  <AREA SHAPE=RECT COORDS="3,18,157,29" HREF="gallery.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="33,30,129,42" HREF="dream.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="38,43,125,57" HREF="tipsb.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="17,69,143,82" HREF="free.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="28,84,134,95" HREF="house.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="35,95,129,109" HREF="unit.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="29,111,132,121" HREF="agent.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="18,122,144,136" HREF="marketing.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="18,148,143,161" HREF="finance.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="20,163,140,173" HREF="insurance.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="9,176,150,187" HREF="moving.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="14,189,146,202" HREF="links.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="28,215,135,226" HREF="about.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="22,228,140,240" HREF="about2.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
  <AREA SHAPE=RECT COORDS="27,242,135,253" HREF="contact.html" ALT="" OnMouseOut="window.status=''; return true" OnMouseOver="window.status=''; return true">
</MAP>




ChrisScott April 26th, 2004 03:47 AM

Hi Luke,

Your body onload attribute should be...

onload="changeScreenSize(800,600); slideit();"

The reason your slide show isn't working is because of these lines...

var Image2=new Image()
var Image3=new Image()

and then accessing them with eval("image"+step+".src")

so you are looking for image2.src, image3.src - remember javascript is case sensitive so you need...

var image2=new Image()
var image3=new Image()

IMHO I would steer clear of resizing the window everytime a user opens you site, this just tends to wind people up, if you want the page to be 800 * 600, why not just place the content in a div that size (you could also center it if you wanted), this is pretty much the norm on the net e.g. news.bbc.co.uk

Best regards,

Chris




All times are GMT -4. The time now is 08:53 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.