Current status of the Ning Platform is always available on the Ning Status Blog.

Forum

Can you delay a certain script?

Hello Creators, I am experimenting with a new feature for my network, however the JavaScripts are conflicting if the page takes too long to load. Is it possible to delay one of my scripts somehow?

Thanks everyone. Take care.

You need to be a member of Ning Creators Network to add comments!

Join Ning Creators Network

Email me when people reply –

Replies

  • If someone can teach me how to delay a script from loading, I will release an amazing TIP.

    What TIP you ask?

    How about letting your members choose what style sheet they prefer (light/dark/holiday) and have a cookie remember their choice?

    It's possible, I've had it working (not easy) but my problem is that it conflicts with my jquery tabs. So I need to delay the styleswitcher script so that there are not these conflicts.

    Thanks guys, I'd love some help.

  • I'm pretty sure that this is close to the right track....

    Needs a bit of altering, and I need to learn where I am to implement this, and how to apply it to my styleswitcher script.

    onClick="setTimeout(function() {alert('hello');},1250);

    Wouldn't want the alert part, but the timing delay function is there. 1250 milliseconds.

  • So this gives a delayed pop up message. How do I convert this to happen for my styleswitcher script, without the pop up of course.

    <form>
    <input type="button" value="Push this button to open an alert box in 1250 milliseconds" onClick="setTimeout(function() {alert('hello');},1250);">
    </form>

  • There's also a small issue with my styleswitcher script. I'll address that if I end up posting the TIP. It's pretty advanced in my opinion.

    Seems that on the first stylesheet, everything is fine, then switch to stylesheet 2, and my ningbar no longer is fixed, and that whole top section is wacky.

    I know you all won't have a clue what I'm talking about, until you see the scripts.

    Perhaps I'll just post the TIP and see what happens.

    • NC for Hire

      Hi Damien ,

      i normally use jQuery to do this :

      This script is to wait the window to complete loading then carry out the javascript

      $(window).load(function(){

         //javascript code goes here.

      });

      • Awesome Elson, that looks like it would work beautifully, and even looks easy to implement... now can I just delay the call to the script?

        $(window).load(function(){

        <link rel="stylesheet" type="text/css" href="http://api.ning.com/files/jwktXyJ4GnEIIluAAOY2mTQ6e*iEDVDGj2EDQDxGLzz-tEkbxOz6vD3IHWSSRlM2uLAs-SnptBR7X3LcvpzLGb8dwWNW*d3N/APStyleSheet.css" />

        });

        • That's my stylesheet, I know, but will it work like this?

          • NC for Hire

            Do it like this:

            $(window).load(function(){

               $('head').append('<link rel="stylesheet" type="text/css" href="http://api.ning.com/files/jwktXyJ4GnEIIluAAOY2mTQ6e*iEDVDGj2EDQDxGLzz-tEkbxOz6vD3IHWSSRlM2uLAs-SnptBR7X3LcvpzLGb8dwWNW*d3N/APStyleSheet.css" />');

            });

            • Ok sorry Elson, this is easier... this is what I need to delay... could you copy and paste, and add the delay for me? I'm failing my attempts.

              <!--trial stylesheet switcher-->
              <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
                  
                  <link rel="stylesheet" type="text/css" href="http://api.ning.com/files/jwktXyJ4GnEIIluAAOY2mTQ6e*iEDVDGj2EDQDxGLzz-tEkbxOz6vD3IHWSSRlM2uLAs-SnptBR7X3LcvpzLGb8dwWNW*d3N/APStyleSheet.css" title="styles1" media="screen" />
                  <link rel="alternate stylesheet" type="text/css" http://api.ning.com/files/6dRGUjTYClcg8NTa4pZGB8sk7LHCbUboLSQ0qY74i...*fJoxnvqgv7/APStyleSheetdark.css" title="styles2" media="screen" />
                  <link rel="alternate stylesheet" type="text/css" href="http://api.ning.com/files/j4wABojellApIBhmYmDsM277fce8Nxo89VvZ-RBKHE*TIWgXmeZQdVXrmacxm--bxgjgmBoGhEE76hH4ZbVfclB9ARHpD33o/NewStyleSheet1.css" title="styles3" media="screen" />
                  
                  <script type="text/javascript" src="http://api.ning.com:80/files/m9wY6nHswW4dI-dqxiJ62s9a5Q6jo-PHP*pU83VVJlsw*eFlDZ3h3TlV8-BFyIp7pNkB-FthX4a8PnmCJkWwQRGPyeTd1zN0/1059817952.bin"></script>
                  <script type="text/javascript" src="http://api.ning.com:80/files/m9wY6nHswW5L0BMsh0DGsQr3-6KMC*ooOuaJHf2*UQNNCs83xyTvlMmWkxjBOTb1O5cmE3Qyym171Rw834HlqnQSv2k*tYN9/1059817955.bin"></script>
              <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              <!-- TemplateBeginEditable name="doctitle" -->
              <!--end trial stylesheet switcher-->

              • Also, you know my fixed ningbar? When I switch to 2nd and 3rd stylesheet, the ningbar is no longer fixed, and all of the stuff in the ningbar is no longer in there. (account module returns to left column, navigation is no longer in ningbar, and ningbar is no longer widened. Seems like the stylesheets don't fully load or something? Not sure if you'll know an answer for this, and I may have to design the 2nd and 3rd stylesheets to not have a fixed ningbar, and think up something different.

This reply was deleted.

Search the Creators Network

Latest Activity

George H. Compton IV replied to George H. Compton IV's discussion A tip all Ning3 networks can benefit from. "fluid YouTube & Vimeo Videos" N3
"Thank you Dave :-) you have a very Merry Christmas as well. :-)"
1 hour ago
George H. Compton IV replied to John Bizley's discussion My Completed Video List Page and Main Viewing Page
"Awesome job John it's simply beautiful. :-)"
1 hour ago
Zachary Moonshine replied to Anant Garg's discussion CometChat Network Edition now available for NING
"email just now sent i included 2 snap shots of what i see and the links"
3 hours ago
Anant Garg replied to Anant Garg's discussion CometChat Network Edition now available for NING
"Please email us at help@cometchat.com and we will assist you further."
3 hours ago
Zachary Moonshine replied to Anant Garg's discussion CometChat Network Edition now available for NING
"yeah i just tried that same thing man no luck "
3 hours ago
dave replied to George H. Compton IV's discussion A tip all Ning3 networks can benefit from. "fluid YouTube & Vimeo Videos" N3
"Nice work George :-) working fantastic and thanks for sharing this :-) 
Christmas is not far away s…"
7 hours ago
Ceddy J replied to John Bizley's discussion My Completed Video List Page and Main Viewing Page
"How does it work and how do people who are on mobile use it?"
10 hours ago
Anant Garg replied to Anant Garg's discussion CometChat Network Edition now available for NING
"Hello,
You need to first associate the HTM file in your Ning Admin Panel and then update the URL in…"
11 hours ago
Zachary Moonshine replied to John Bizley's discussion My Completed Video List Page and Main Viewing Page
"very cool john "
13 hours ago
Zachary Moonshine replied to Luke Jones's discussion Hey :)
"check out the thread in here about alternatives to ning. there is some pretty cool stuff out there.…"
16 hours ago
Zachary Moonshine replied to Luke Jones's discussion Hey :)
"i am starting to gather that ning 3 is just not for social networks. it looks like it is but when y…"
16 hours ago
Az'ya replied to Jeffrey Haskins's discussion Am I missing...but is there a way to duplicate a page rather then having to build pages that are similar
"I find it hard to believe this feature isn't available... still (or am I missing something)? It wou…"
16 hours ago
Writer Chick {Diane} replied to Zachary Moonshine's discussion How to stop spammers ning 3 ?
"I require a profile picture. That stops 99% of the spamming. "
18 hours ago
Shelly Begarowicz replied to George H. Compton IV's discussion A tip all Ning3 networks can benefit from. "fluid YouTube & Vimeo Videos" N3
"THANK YOU!  Both for the clarification and for the brilliant code!  This will make things so much e…"
19 hours ago
Zachary Moonshine replied to Zachary Moonshine's discussion Fixed menu at the top Ning 3 ?
"ahh i see now i added more space to the header and now it looks great this is perfect man and proba…"
20 hours ago
Zachary Moonshine replied to Zachary Moonshine's discussion Fixed menu at the top Ning 3 ?
"Thank you George, for some reason on my screen the menu is on top of the logo ?"
20 hours ago
Zachary Moonshine replied to Anant Garg's discussion CometChat Network Edition now available for NING
"Ok so i am checking this out now just installed it and followed the instructions i want to be able…"
21 hours ago
Zachary Moonshine replied to Anant Garg's discussion CometChat is now available for NING
"Ok so i am checking this out now just installed it and followed the instructions i want to be able…"
21 hours ago
soaringeagle replied to Brandon Owens's discussion 3 essential back-end changes that Ning could make to increase Everyone's traffic
"haha well the 1  gallery update we asked for did seem to  show up in seconds but nobody can code th…"
21 hours ago
George H. Compton IV replied to Zachary Moonshine's discussion Fixed menu at the top Ning 3 ?
"@media screen and (min-width:1000px) { NAV.navbar {    position: fixed;    top:30px;    left:0px;…"
21 hours ago
More…