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

Strumelia replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"Steve, this is also an enlightening discussion, from a year ago as well:
http://creators.ning.com/a&hellip;"
27 minutes ago
Strumelia replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"Steve, if you read this discussion from start to finish:
http://creators.ning.com/announcements-fro&hellip;"
48 minutes ago
steve replied to Aubrey Williams's discussion How to get networking members interacting with each other?
"Blimey thats a bit of a "How long is a piece of string" question is that Aubrey.. Depends what you…"
1 hour ago
steve replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"I think it was here i got my information from, this is an update and you will see from the heading…"
1 hour ago
steve replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"Fear is a terrible thing Terry, specially if you have a Ning 2 which may be close to renewal, a sto…"
1 hour ago
Terry Henderson replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"Thanks - but don't worry about me - I can give as good as I get if I felt someone was trying to bul…"
3 hours ago
Terry Henderson replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"I just looked up my old email - on 3/14/14 I got an email saying 3.0 Phase One was ready and my sit…"
3 hours ago
Strumelia replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"I believe you Terry- I have heard now and then of inconsistencies in Ning payment support (or non-s…"
3 hours ago
Solael replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"Something does not sound right. But okay...your story is your story."
4 hours ago
mysticpagan replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"I have been getting notifications in my email regarding this discussion and I just wanted to say it…"
4 hours ago
Terry Henderson replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"No - my account had not lapsed.  It was a month or two before it was due.  But my account had over…"
4 hours ago
soaringeagle replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"then why is it it only happened to you and everyone else has had no trouble renewing thier 2.0
mayb…"
4 hours ago
Donna Mac replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"This drama is ridiculous.  RI DIC U LOUS.  All this in-fighting amongst each other.  Thanks Ning."
4 hours ago
Strumelia replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"Terry, had you let your payment/renewal lapse or expire unpaid for a few weeks or more before you a…"
4 hours ago
Strumelia replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"Allison/Crystal made it quite clear that Ning had dropped all migration deadlines for the time bein…"
4 hours ago
Terry Henderson replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"I was on this thread before and started getting the new email - I tried my login and it worked - wh…"
4 hours ago
Terry Henderson replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"All I know is they contacted me and told my I HAD to upgrade to renew - I told them I didn't want t…"
5 hours ago
Solael replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"I am not supporting anyone here on this, however there are two sides to every story. No one will di…"
5 hours ago
Scott Bishop replied to Allison Leahy's discussion What are you most excited about?
"I'm most exited about George H. Compton IV responsive design for N2. Works much better than N3 and…"
5 hours ago
soaringeagle replied to Allison Leahy's discussion Changes to Ning 3.0 Based on Your Feedback
"and to clarify you have a year to a year and 1/2 after stage 3 migration tools aree in place so far…"
5 hours ago
More…