Hi
I have this line of code
<div id="mainContent" onclick="new
Effect.SlideDown(this);window.setTimeout(''Effect.Appear(\''demo-effect-
slideup\'', {duration:.3})'',2500);">
which works fine, but what I want to do is make work on an onLoad
command I have tried this
<body onLoad="new Effect.SlideDown(mainContent);
window.setTimeout(''Effect.Appear(\''demo-effect-slideup\'',
{duration:.
3})'',2500);">
but fails to work! Can any one point me in the right direction
thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi fazz,
it''s not a good practice to put code directly into the onLoad Event of
the body tag.
It''s better you do something like this in your <head> section or
an
external linked js:
---
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != ''function'') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
Effect.SlideDown(document.getElementById(''mainContent''));
window.setTimeout(''Effect.Appear(''demo-effect-slideup'',
{duration:.
3})'',2500);
})
---
should work.
bye,
Thomas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi Thomas Thanks for this I am quite new to this stuff, I have added the function in to the head of my document should it have some sort of tag around the code? On Sep 17, 10:48 am, Thomas Murphy <murphs...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi fazz, > > it''s not a good practice to put code directly into the onLoad Event of > the body tag. > It''s better you do something like this in your <head> section or an > external linked js: > > --- > function addLoadEvent(func) { > var oldonload = window.onload; > if (typeof window.onload != ''function'') { > window.onload = func; > } else { > window.onload = function() { > if (oldonload) { > oldonload(); > } > func(); > } > } > > } > > addLoadEvent(function() { > Effect.SlideDown(document.getElementById(''mainContent'')); > window.setTimeout(''Effect.Appear(''demo-effect-slideup'', {duration:. > 3})'',2500); > > }) > > --- > > should work. > bye, > Thomas--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Sorry
I have linked this into an external file and hooked it up like this:
<script src="javascripts/function.js"
type="text/javascript"></script>
The mainContent css div is this
#mainContent {
background-color: #CCCCCC;
height: 505px;
width: 881px;
float: left;
background-image: url(background2.png);
background-repeat: repeat;
padding-top: 5px;
padding-right: 5px;
padding-bottom: 5px;
padding-left: 5px;
display: none;
}
But I still can''t get it to work
help!!!! Please!!!
On Sep 17, 10:55 am, fazz
<rob.farr...-xQZSoECJ7frBHMYPpBSspA@public.gmane.org>
wrote:> Hi Thomas
>
> Thanks for this I am quite new to this stuff, I have added the
> function in to the head of my document should it have some sort of tag
> around the code?
>
> On Sep 17, 10:48 am, Thomas Murphy
<murphs...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:
>
> > Hi fazz,
>
> > it''s not a good practice to put code directly into the onLoad
Event of
> > the body tag.
> > It''s better you do something like this in your <head>
section or an
> > external linked js:
>
> > ---
> > function addLoadEvent(func) {
> > var oldonload = window.onload;
> > if (typeof window.onload != ''function'') {
> > window.onload = func;
> > } else {
> > window.onload = function() {
> > if (oldonload) {
> > oldonload();
> > }
> > func();
> > }
> > }
>
> > }
>
> > addLoadEvent(function() {
> >
Effect.SlideDown(document.getElementById(''mainContent''));
> >
window.setTimeout(''Effect.Appear(''demo-effect-slideup'',
{duration:.
> > 3})'',2500);
>
> > })
>
> > ---
>
> > should work.
> > bye,
> > Thomas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
First, Prototype provides you with Event.observe that solves the
addLoadEvent in one line :)
Event.observe(window, "load", function() {
new Effect.SlideDown(...);
});
Don''t forget the ''new'' before Effect.SlideDown and
Effect.Appear!
And finally, try moving the ''display: none'' from the
stylesheet into the html
<div id="mainContent" style="display: none;">
As javascript won''t update the display correctly when set in the css
file.
Best,
-Nicolas
On 9/17/07, fazz <rob.farrell-xQZSoECJ7frBHMYPpBSspA@public.gmane.org>
wrote:>
> Sorry
>
> I have linked this into an external file and hooked it up like this:
>
> <script src="javascripts/function.js"
type="text/javascript"></script>
>
> The mainContent css div is this
> #mainContent {
> background-color: #CCCCCC;
> height: 505px;
> width: 881px;
> float: left;
> background-image: url(background2.png);
> background-repeat: repeat;
> padding-top: 5px;
> padding-right: 5px;
> padding-bottom: 5px;
> padding-left: 5px;
> display: none;
> }
>
>
> But I still can''t get it to work
>
>
> help!!!! Please!!!
> On Sep 17, 10:55 am, fazz
<rob.farr...-xQZSoECJ7frBHMYPpBSspA@public.gmane.org> wrote:
> > Hi Thomas
> >
> > Thanks for this I am quite new to this stuff, I have added the
> > function in to the head of my document should it have some sort of tag
> > around the code?
> >
> > On Sep 17, 10:48 am, Thomas Murphy
<murphs...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:
> >
> > > Hi fazz,
> >
> > > it''s not a good practice to put code directly into the
onLoad Event of
> > > the body tag.
> > > It''s better you do something like this in your
<head> section or an
> > > external linked js:
> >
> > > ---
> > > function addLoadEvent(func) {
> > > var oldonload = window.onload;
> > > if (typeof window.onload != ''function'') {
> > > window.onload = func;
> > > } else {
> > > window.onload = function() {
> > > if (oldonload) {
> > > oldonload();
> > > }
> > > func();
> > > }
> > > }
> >
> > > }
> >
> > > addLoadEvent(function() {
> > >
Effect.SlideDown(document.getElementById(''mainContent''));
> > >
window.setTimeout(''Effect.Appear(''demo-effect-slideup'',
{duration:.
> > > 3})'',2500);
> >
> > > })
> >
> > > ---
> >
> > > should work.
> > > bye,
> > > Thomas
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
I now have this as an linked js file
// JavaScript Document
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != ''function'') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
new
Effect.SlideDown(document.getElementById(''mainContent''));
window.setTimeout(''new
Effect.Appear(''demo-effect-slideup'',
{duration:.3})'',2500);
})
and this on the html page
<div id="mainContent" style="display: none;">
Now it does not display the main content at all!!!!!
On Sep 17, 2:30 pm, "Nicolás Sanguinetti"
<godf...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> First, Prototype provides you with Event.observe that solves the
> addLoadEvent in one line :)
>
> Event.observe(window, "load", function() {
> new Effect.SlideDown(...);
>
> });
>
> Don''t forget the ''new'' before Effect.SlideDown
and Effect.Appear!
> And finally, try moving the ''display: none'' from the
stylesheet into the html
>
> <div id="mainContent" style="display: none;">
>
> As javascript won''t update the display correctly when set in the
css file.
>
> Best,
> -Nicolas
>
> On 9/17/07, fazz
<rob.farr...-xQZSoECJ7frBHMYPpBSspA@public.gmane.org> wrote:
>
>
>
>
>
> > Sorry
>
> > I have linked this into an external file and hooked it up like this:
>
> > <script src="javascripts/function.js"
type="text/javascript"></script>
>
> > The mainContent css div is this
> > #mainContent {
> > background-color: #CCCCCC;
> > height: 505px;
> > width: 881px;
> > float: left;
> > background-image: url(background2.png);
> > background-repeat: repeat;
> > padding-top: 5px;
> > padding-right: 5px;
> > padding-bottom: 5px;
> > padding-left: 5px;
> > display: none;
> > }
>
> > But I still can''t get it to work
>
> > help!!!! Please!!!
> > On Sep 17, 10:55 am, fazz
<rob.farr...-xQZSoECJ7frBHMYPpBSspA@public.gmane.org> wrote:
> > > Hi Thomas
>
> > > Thanks for this I am quite new to this stuff, I have added the
> > > function in to the head of my document should it have some sort
of tag
> > > around the code?
>
> > > On Sep 17, 10:48 am, Thomas Murphy
<murphs...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:
>
> > > > Hi fazz,
>
> > > > it''s not a good practice to put code directly into
the onLoad Event of
> > > > the body tag.
> > > > It''s better you do something like this in your
<head> section or an
> > > > external linked js:
>
> > > > ---
> > > > function addLoadEvent(func) {
> > > > var oldonload = window.onload;
> > > > if (typeof window.onload !=
''function'') {
> > > > window.onload = func;
> > > > } else {
> > > > window.onload = function() {
> > > > if (oldonload) {
> > > > oldonload();
> > > > }
> > > > func();
> > > > }
> > > > }
>
> > > > }
>
> > > > addLoadEvent(function() {
> > > >
Effect.SlideDown(document.getElementById(''mainContent''));
> > > >
window.setTimeout(''Effect.Appear(''demo-effect-slideup'',
{duration:.
> > > > 3})'',2500);
>
> > > > })
>
> > > > ---
>
> > > > should work.
> > > > bye,
> > > > Thomas- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
I''ve only a concern about using style="display:none;" directly into the div (I used this solution because I couldn''t find a better one). If javascript is disabled the visitor will not be able to see the div. It''d be nice if it was possible to hide the div with javascript before loading the images (my div has a backgroung image) .Stefano Nicolás Sanguinetti ha detto: in data 17/09/2007 15:30:> First, Prototype provides you with Event.observe that solves the > addLoadEvent in one line :) > > Event.observe(window, "load", function() { > new Effect.SlideDown(...); > }); > > Don''t forget the ''new'' before Effect.SlideDown and Effect.Appear! > And finally, try moving the ''display: none'' from the stylesheet into the html > > <div id="mainContent" style="display: none;"> > > As javascript won''t update the display correctly when set in the css file. > > Best, > -Nicolas > > On 9/17/07, fazz <rob.farrell-xQZSoECJ7frBHMYPpBSspA@public.gmane.org> wrote: > >> Sorry >> >> I have linked this into an external file and hooked it up like this: >> >> <script src="javascripts/function.js" type="text/javascript"></script> >> >> The mainContent css div is this >> #mainContent { >> background-color: #CCCCCC; >> height: 505px; >> width: 881px; >> float: left; >> background-image: url(background2.png); >> background-repeat: repeat; >> padding-top: 5px; >> padding-right: 5px; >> padding-bottom: 5px; >> padding-left: 5px; >> display: none; >> } >> >> >> But I still can''t get it to work >> >> >> help!!!! Please!!! >> On Sep 17, 10:55 am, fazz <rob.farr...-xQZSoECJ7frBHMYPpBSspA@public.gmane.org> wrote: >> >>> Hi Thomas >>> >>> Thanks for this I am quite new to this stuff, I have added the >>> function in to the head of my document should it have some sort of tag >>> around the code? >>> >>> On Sep 17, 10:48 am, Thomas Murphy <murphs...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >>> >>> >>>> Hi fazz, >>>> >>>> it''s not a good practice to put code directly into the onLoad Event of >>>> the body tag. >>>> It''s better you do something like this in your <head> section or an >>>> external linked js: >>>> >>>> --- >>>> function addLoadEvent(func) { >>>> var oldonload = window.onload; >>>> if (typeof window.onload != ''function'') { >>>> window.onload = func; >>>> } else { >>>> window.onload = function() { >>>> if (oldonload) { >>>> oldonload(); >>>> } >>>> func(); >>>> } >>>> } >>>> >>>> } >>>> >>>> addLoadEvent(function() { >>>> Effect.SlideDown(document.getElementById(''mainContent'')); >>>> window.setTimeout(''Effect.Appear(''demo-effect-slideup'', {duration:. >>>> 3})'',2500); >>>> >>>> }) >>>> >>>> --- >>>> >>>> should work. >>>> bye, >>>> Thomas >>>> >> > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---