Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | 512mb usb flash drives

You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Computers & IT > General IT Discussion

Need some javascript help
Reply
 
Thread Tools
Old 28-09-2004, 09:09   #1
Bifta
Inactive
 
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
Bifta has a nice shiny starBifta has a nice shiny star
Bifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny star
Need some javascript help

I have a popup window which uses an animated DIV that a customer want's to only show on certain day's, I've got the day of the week (number) from using

Code:
<SCRIPT LANGUAGE="JavaScript">
today = new Date();
day = today.getDay();
</SCRIPT>
So for example, if day=2,5 or 7 then I want it to do the following:

Code:
<script language="JavaScript">
if (document.all) {
   w = document.body.clientWidth;
   h = document.body.clientHeight;
}
else if (document.layers) {
   w = window.innerWidth;
   h = window.innerHeight;
}
var popW = 517, popH = 417;
var leftPos = (w-popW)/2;
document.write('<div id="dropin" style="z-index:12;position:absolute;visibility:hidden;left:'+leftPos+'px;top:100px;width:517px;height:417px;filter:Shadow(color=gray,offX=-5,offY=-5,direction=145)">'); 
</script>
<table width="500" border="0" cellpadding="5" cellspacing="1" bgcolor="#41738D">
                <tr> 
                  <td height="160" valign="top" bgcolor="#F0F5F7">
                    <table width="100%" border="0" cellspacing="0" cellpadding="1">
					<tr><td><div align="right"><a href="#" onClick="dismissbox();return false"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Close<strong> 
              [ X ] </strong></font></a></div></td></tr></table>
					<table width="100%" border="0" cellspacing="0" cellpadding="5">
                      <tr> 
                        <td valign="top"><p>                                                  
                        <p align="center"><strong><font color="#FF6600">POP UP WINDOW CONTENTS GO IN HERE<br>
                              <br><script language=javascript>document.write(day);</script>

 
                        </font></strong></p>                          </td>
                      </tr>
                    </table>
                  </td>
                </tr>
              </table>
</div>
And if the day isn't one of them values .. not show it...

thanks.
Bifta is offline   Reply With Quote
Advertisement
Old 28-09-2004, 10:49   #2
Caspar
Inactive
 
Join Date: Jun 2003
Location: UK
Posts: 4,988
Caspar has reached the bronze age
Caspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze age
Re: Need some javascript help

Basic syntax is as below:

Code:
<SCRIPT LANGUAGE="JavaScript">
today = new Date();
day = today.getDay();

if (day == "2") {
	document.write ("Launch popup")
}	
else {
	document.write ("don't launch popup")
}
</script>
Caspar is offline   Reply With Quote
Old 28-09-2004, 11:01   #3
Caspar
Inactive
 
Join Date: Jun 2003
Location: UK
Posts: 4,988
Caspar has reached the bronze age
Caspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze age
Re: Need some javascript help

Ok my revised code:

index.htm
//File that loads the script
Code:
<SCRIPT LANGUAGE="JavaScript">
today = new Date();
day = today.getDay();

if (day == "2") {
	window.open('newwindow.htm','','scrollbars=yes,resizable=no');
}	
</script>

newwindow.htm
//contents of the popup
Code:
<SCRIPT LANGUAGE="JavaScript">
	if (document.all) {
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}
	var popW = 517, popH = 417;
	var leftPos = (w-popW)/2;
	document.write('<div id="dropin" style="z-index:12;position:absolute;visibility:hidden;left:  '+leftPos+'px;top:100px;width:517px;height:417px;filter:Shadow(color=gray,offX=-5,offY=-5,direction=145)">'); 
	</script>
	<table width="500" border="0" cellpadding="5" cellspacing="1" bgcolor="#41738D">
                <tr> 
                  <td height="160" valign="top" bgcolor="#F0F5F7">
                    <table width="100%" border="0" cellspacing="0" cellpadding="1">
					<tr><td><div align="right"><a href=javascript:void(top.close());><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Close<strong> 
              [ X ] </strong></font></a></div></td></tr></table>
					<table width="100%" border="0" cellspacing="0" cellpadding="5">
                      <tr> 
                        <td valign="top"><p>                                                  
                        <p align="center"><strong><font color="#FF6600">POP UP WINDOW CONTENTS GO IN HERE<br>
                              <br><script language=javascript>document.write(day);</script>

 
                        </font></strong></p>                          </td>
                      </tr>
                    </table>
                  </td>
                </tr>
    </table>
	</div>
</script>
Caspar is offline   Reply With Quote
Old 28-09-2004, 11:02   #4
Bifta
Inactive
 
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
Bifta has a nice shiny starBifta has a nice shiny star
Bifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny star
Re: Need some javascript help

Quote:
Originally Posted by Caspar
Basic syntax is as below:

Code:
<SCRIPT LANGUAGE="JavaScript">
today = new Date();
day = today.getDay();

if (day == "2") {
	document.write ("Launch popup")
}	
else {
	document.write ("don't launch popup")
}
</script>
So I have to stick the whole of the extra javascript and HTML in document.writes? Parsing that is going to be a nightmare .. think I'll tell them it can't be done with JS and coax them into letting me do it with ASP

The popup isn't actually a new window as such, it's a div and it's part of the page so it can't appear in a new window.
Bifta is offline   Reply With Quote
Old 28-09-2004, 11:07   #5
Caspar
Inactive
 
Join Date: Jun 2003
Location: UK
Posts: 4,988
Caspar has reached the bronze age
Caspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze age
Re: Need some javascript help

Yeah, i decided not to encapsulate your code into doc.writes aswell!!!

so I opted for a new window angle, see above
Caspar is offline   Reply With Quote
Old 28-09-2004, 14:02   #6
punky
Inactive
 
Join Date: Jun 2003
Age: 44
Posts: 14,750
punky has a golden aurapunky has a golden aura
punky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aura
Re: Need some javascript help

Also, if you want to do 2 or 5 or 7, you can do it like this:

if ((var ==2) || (var == 5) || (var == 7))
{
//display window
}

Just for reference, if you want two vars to be certain values, you can use && for and
punky is offline   Reply With Quote
Old 28-09-2004, 14:13   #7
Bifta
Inactive
 
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
Bifta has a nice shiny starBifta has a nice shiny star
Bifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny star
Re: Need some javascript help

It's ok, now he's decided he wants the DIV to show based on a cookie ... so this can be closed I guess, sorry for wasting your time
Bifta is offline   Reply With Quote
Old 28-09-2004, 15:27   #8
Caspar
Inactive
 
Join Date: Jun 2003
Location: UK
Posts: 4,988
Caspar has reached the bronze age
Caspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze ageCaspar has reached the bronze age
Re: Need some javascript help

np
Caspar is offline   Reply With Quote
Old 28-09-2004, 17:38   #9
Matth
Inactive
 
Join Date: Mar 2004
Services: BB:M, TV:XL, Phone:M, Loyalty
Posts: 2,516
Matth has reached the bronze age
Matth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze ageMatth has reached the bronze age
Re: Need some javascript help

If it's one of those blasted DIV pseudo popups, tell him it won't win any friends!

http://www.kephyr.com/popupkillertest/index.html - Test your browser and blocker against many popups and variants here - if you can get a clean slate against some of the obscure variants, you're probably running Mozilla!
Matth is offline   Reply With Quote
Old 28-09-2004, 18:06   #10
Bifta
Inactive
 
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
Bifta has a nice shiny starBifta has a nice shiny star
Bifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny star
Re: Need some javascript help

Quote:
Originally Posted by Matth
If it's one of those blasted DIV pseudo popups, tell him it won't win any friends!

http://www.kephyr.com/popupkillertest/index.html - Test your browser and blocker against many popups and variants here - if you can get a clean slate against some of the obscure variants, you're probably running Mozilla!
Doesn't matter whether it wins him any friends or not, it's only going to advertise his services, on his own site and as he's a paying customer, he can have the moon on a stick if he's willing to part with the cash for it.
Bifta is offline   Reply With Quote
Old 28-09-2004, 20:53   #11
Richard M
Inactive
 
Join Date: Jun 2003
Location: Los Angeles, CA
Age: 46
Posts: 6,343
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Re: Need some javascript help

Quote:
Originally Posted by Caspar
Yeah, i decided not to encapsulate your code into doc.writes aswell!!!

so I opted for a new window angle, see above
He needs to be using HTML+CSS (DHTML) for this, if I've read between the lines correctly.
Just like those annoying adverts that popup over the text of the page you're reading on some sites.
Richard M is offline   Reply With Quote
Reply

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

Forum Jump


All times are GMT. The time now is 21:05.


Server: lithium.zmnt.uk
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum