Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.3k views
in Q2A Core by

I want to add some modification and it requred javascript function to work but don't know where to add this javascirpt pl suggest

 

var containerheight = 0;
var numbercount = 0;
var liheight;
var index = 1;

function callticker() {    
    $(".container ul").animate({
        "margin-top": (-1) * (liheight * index)
    }, 2500);
    if (index != numbercount - 1) {
        index = index + 1;
    }
    else {
        index = 0;
    }
    timer = setTimeout("callticker()", 100);
}
$(document).ready(function() {
    numbercount = $(".container ul li").size();
    liheight = $(".container ul li").outerHeight();
    containerheight = $(".container ul  li").outerHeight() * numbercount;
    $(".container ul").css("height", containerheight);
    var timer = setTimeout("callticker()", 100);
}); 

2 Answers

+2 votes
by
by using the layers you can perform such operations -

 

follow up with the instructions and examples here -

http://www.question2answer.org/layers.php
+2 votes
by

You can modify your qa-theme.php this way:

function doctype() {
   qa_html_theme_base::doctype();
   $script = <<<JS
      <script>
         alert("hello");
      </script>
JS;
   $this->content['body_footer'] = (isset($this->content['body_footer']) ? $this->content['body_footer'] : '') . $script;
}

Respect the spacing in <<<JS and JS;.
 
If this shows the alert then this is working. You should now replace alert("hello"); with the given JS code. After that, it is a matter of making your JS code work :)
by
Thats great . It is also a Good Idea .
by
There are indeed a few more alternatives. EG: You can also add it in the head tag. I personally like the plugin idea more but the user will have to know how to create a plugin. Not hard but still more complex than what the average user expects.
by
Thanks a lot for the tip :)
...