I have an interesting problem!
I'm using WAMP to test all this out and on my local machine everything works a treat...but when I upload and go live, not all the buildings can be dragged!
Again, works perfectly on my local machine...so I don't "get it".
I am using the "save to cookie" found here for 21 draggable buildings in my virtual world: http://www.dynamicdrive.com/forums/s...drag+drop+save
Why would everything work great on my local machine with WAMP but not live on the internet??
The way I'm using the cookie code from the sited thread is like this (not sure if this has anything to do with it so thought I'd post it--I am showing 3 buildings only as an example, there are actually 21 in total):
Code:
<script type="text/javascript">
/////building1
var building1=document.getElementById("building1")
Drag.init(building1)
building1.onDragEnd=function(x, y){
setCookie("building1", x+"||"+y, 30)
}
if (getCookie("building1")!=""){
var building1cookie=getCookie("building1").split("||")
document.getElementById("building1").style.left=parseInt(building1cookie[0])+"px"
document.getElementById("building1").style.top=parseInt(building1cookie[1])+"px"
}
/////building2
var building2=document.getElementById("building2")
Drag.init(building2)
building2.onDragEnd=function(x, y){
setCookie("building2", x+"||"+y, 30)
}
if (getCookie("building2")!=""){
var building2cookie=getCookie("building2").split("||")
document.getElementById("building2").style.left=parseInt(building2cookie[0])+"px"
document.getElementById("building2").style.top=parseInt(building2cookie[1])+"px"
}
/////building3
var building3=document.getElementById("building3")
Drag.init(building3)
building3.onDragEnd=function(x, y){
setCookie("building3", x+"||"+y, 30)
}
if (getCookie("building3")!=""){
var building3cookie=getCookie("building3").split("||")
document.getElementById("building3").style.left=parseInt(building3cookie[0])+"px"
document.getElementById("building3").style.top=parseInt(building3cookie[1])+"px"
}
///////Cookie Creation for the buildings
function getCookie(Name){
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value--this can be saved to database?
return ""
}
function setCookie(name, value, days){
var expireDate = new Date() //set "expstring" to either an explicit date (past or future)
var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/"
}
</script>
Now, the way I am incorporating this is that I put all this cookie stuff in a file called "town_js.php" and in my town.php, I made an include at the bottom, after all the building code like this:
Code:
<?php include'town_js.php'; ?>
In my header file I have the <script type="text/javascript" src="dom-drag.js"></script> and <body onLoad=" Drag.init();">
Bookmarks