PDA

View Full Version : Ajax Tabs Content Script problem



suv
09-21-2009, 11:19 AM
1) Script Title: Ajax Tabs Content Script (v 2.2)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm

3) Describe problem:
If the script tags are not just above the </body>, the script has no effect whatsoever.
Is there a way in which the script content could be moved in the external js and perhaps calling the action with onClick or onMouseOver? Hence avoiding a rather wrong positioning of the script tags. in the body.

ddadmin
09-22-2009, 05:23 AM
If the script tags are not just above the </body>, the script has no effect whatsoever.

Versus where on the page? In general as long as the SCRIPT tag is defined before the initialization code (ie: new ddajaxtabs("countrytabs", "countrydivcontainer")) is called on the page, it should work.


Is there a way in which the script content could be moved in the external js and perhaps calling the action with onClick or onMouseOver?

By script content, do you mean the HTML for each "tabbed" content? If so, the script already supports that, through either Ajax or IFRAME.

suv
09-23-2009, 07:15 PM
By script content, do you mean the HTML for each "tabbed" content?
What I meant is the content inside the <script> tags, where you declare the function ddajaxtabs ans assign it to a new variable.
Is it possible somehow to move this part in the external javascript file so it can be called on mouse over or on click from the <a> tag.

This way we can avoid the problem with positioning the <script> tags, which as I said before, if you don't put the just before </body> the end of the body tag, they have no effect whatsoever.
I've tried to insert it elsewhere in the body but with no success.

simcomedia
09-24-2009, 03:22 AM
I don't understand the problem of just leaving it there... above the </body> tag. That's what SEO guidelines recommend, put it at the bottom of the page.

suv
09-24-2009, 09:24 AM
I don't understand the problem of just leaving it there... above the </body> tag. That's what SEO guidelines recommend, put it at the bottom of the page.
Thanks for the reply.
The problem is that in certain CMS you cannot place it just above the </body> tag due to limited privileges.
So if I try to insert the code using the CMS, it will place it anywhere else but in the proper position... and there the problem appears.

ddadmin
09-24-2009, 07:22 PM
By script content, do you mean the HTML for each "tabbed" content?
What I meant is the content inside the <script> tags, where you declare the function ddajaxtabs ans assign it to a new variable.
Is it possible somehow to move this part in the external javascript file so it can be called on mouse over or on click from the <a> tag.

This way we can avoid the problem with positioning the <script> tags, which as I said before, if you don't put the just before </body> the end of the body tag, they have no effect whatsoever.
I've tried to insert it elsewhere in the body but with no success.

If you mean the invocation code such as:


<script type="text/javascript">

var myflowers=new ddajaxtabs("flowertabs", "flowerdivcontainer")
myflowers.setpersist(true)
myflowers.setselectedClassTarget("link") //"link" or "linkparent"
myflowers.init(3000)

</script>

What you can do is have it run when the page fully loads. This makes it possible for you to place the above anywhere on the page (ie: HEAD section), instead of having to follow the HTML of the Tabs and Tab Contents. To do this, you'd modify the above to become:


<script type="text/javascript">

window.onload=function(){
var myflowers=new ddajaxtabs("flowertabs", "flowerdivcontainer")
myflowers.setpersist(true)
myflowers.setselectedClassTarget("link") //"link" or "linkparent"
myflowers.init(3000)
}

</script>

Note that the above doesn't take into account other scripts also running themselves window.onload, which if there are will fail.

suv
09-26-2009, 04:48 PM
Thanks for the reply, and it failed indeed.

Is there a way in which the script can be moved outside the html file, say in the external js?

suv
09-30-2009, 11:01 PM
Fixed.
it works now, although I'm still wondering how to make it load onMouseOver
anybody? suggestions?