Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 14th, 2003, 03:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
  #2 (permalink)  
Old December 14th, 2003, 08:52 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Because you haven't closed the wheelscroll script tag.

--

Joe
Reply With Quote
  #3 (permalink)  
Old December 22nd, 2003, 01:07 AM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to stalker Send a message via MSN to stalker
Default

nor the REVEAL script first tag

Reply With Quote
  #4 (permalink)  
Old April 23rd, 2004, 02:39 AM
Registered User
 
Join Date: Apr 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to antisprite Send a message via AIM to antisprite Send a message via MSN to antisprite Send a message via Yahoo to antisprite
Default

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>

Reply With Quote
  #5 (permalink)  
Old April 23rd, 2004, 05:20 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Luke,

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

Thanks,

Chris

Reply With Quote
  #6 (permalink)  
Old April 23rd, 2004, 07:53 AM
Registered User
 
Join Date: Apr 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to antisprite Send a message via AIM to antisprite Send a message via MSN to antisprite Send a message via Yahoo to antisprite
Default

/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;">


Reply With Quote
  #7 (permalink)  
Old April 23rd, 2004, 10:37 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

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


Reply With Quote
  #8 (permalink)  
Old April 23rd, 2004, 06:50 PM
Registered User
 
Join Date: Apr 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to antisprite Send a message via AIM to antisprite Send a message via MSN to antisprite Send a message via Yahoo to antisprite
Default

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>



Reply With Quote
  #9 (permalink)  
Old April 26th, 2004, 03:47 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

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


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Design-Time or Run-Time now ? ALGNET .NET Framework 2.0 1 July 31st, 2006 04:43 AM
HOWTO run WSH scripts from ASP?? fhameed Classic ASP Professional 1 July 2nd, 2006 10:55 AM
Run time Help Dazzer96 Access VBA 2 May 3rd, 2006 07:03 AM
I cant run asp scripts majc Classic ASP Basics 4 December 3rd, 2005 06:14 AM
cannot run ASP scripts -Dman100- Classic ASP Databases 7 April 13th, 2004 11:17 PM



All times are GMT -4. The time now is 08:59 PM.


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