WordPress.org

Ready to get started?Download WordPress

Forums

code changing and problems (2 posts)

  1. stifledgenius
    Member
    Posted 1 year ago #

    I made a redirect page to a Squarespace site while I finish creating my WP site. I'm having two issues:

    1. When I write in the code on the page under the html tab, when I switch it to the other tab to see how it will show up and switch back it rewrites the code for some reason. It then breaks the code and makes the countdown timer stop working.

    2. Now the countdown timer has stopped working altogether. I type in the code and don't switch the pains so the code can't be rewritten. Before, the timer worked, now it's completely disappeared.

    Anyone have any suggestions?

    Original Site:
    http://www.msullivanphoto.com

    Redirect Code:
    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser. Or use pastebin.com instead. ]

    <script language="JavaScript" type="text/javascript">
    var count =6
    var redirect="https://michael-sullivan-6tez.squarespace.com/"  
    
    function countDown(){
     if (count <=0){
      window.location = redirect;
     }else{
      count--;
      document.getElementById("timer").innerHTML = "This page will redirect in "+count+" seconds."
      setTimeout("countDown()", 1000)
     }
    }
    </script>  
    
    <p style="text-align: center;"><span style="text-decoration: underline;"><strong>Site Under Construction</strong></span></p>
    <p style="text-align: center;">If you are not redirected to my Squarespace page, please click <a href="https://michael-sullivan-6tez.squarespace.com/">HERE</a>.</p>  
    
    <span id="timer">
    <script>
     countDown();
    </script>
    </span>

    Redirect Code Once It's Been Rewritten by WP:

    <script type="text/javascript" language="JavaScript">// <![CDATA[
    var count =8
    var redirect="https://michael-sullivan-6tez.squarespace.com/"  
    
    function countDown(){
     if (count <=0){
      window.location = redirect;
     }else{
      count--;
      document.getElementById("timer").innerHTML = "This page will redirect in "+count+" seconds."
      setTimeout("countDown()", 1000)
     }
    }
    // ]]></script>
    <p style="text-align: center;"><strong>Site Under Construction</strong></p>
    <p style="text-align: center;">If you are not redirected to my Squarespace page, please click <a href="https://michael-sullivan-6tez.squarespace.com/">HERE</a>.</p>
    <span id="timer">
    <script type="text/javascript">// <![CDATA[
    countDown();
    // ]]></script>
    </span>
    
    <span id="timer">
    <script type="text/javascript">// <![CDATA[
    
     countDown();
    // ]]></script>
    </span>

    Let me end it by saying I'm not a programmer. I found this code and understand how code works and where to put things normally, but I don't know how to write code from scratch. Any help or suggestions would be greatly appreciated :)

  2. 1. When I write in the code on the page under the html tab, when I switch it to the other tab to see how it will show up and switch back it rewrites the code for some reason.

    Without getting into a fairly lengthy conversation regarding the merits of the WordPress post/page editor, the short answer is that posting that code into it (HTML editor or not) will never work reliably. Ever. ;)

    Let me end it by saying I'm not a programmer.

    You don't really need to be exactly but some programming may be necessary.

    Instead of pasting that javascript into your post or page try creating a plugin that lets you paste a shortcode instead. That way you can get that script in place and still view your posts in the editor.

    Or (much easier and probably want you really want/need) you can paste that code into a new page template and the post editor wont be used.

    If you do edit the page template please make sure you have a backup copy first.

Topic Closed

This topic has been closed to new replies.

About this Topic