I’ve run into a bit of problem defining a path to a script. Normally, this wouldn’t seem like it would be a problem but I can’t quite get it working right now.
I have 2 pages.
Page1.html
graph.html
And 1 Javascript
Javascript.js
Page 1
Has a link with the following onclick:
onclick="return GB_showCenter('Data Graph',createGraph('tag'),340,820)"
At this point I have a function called createGraph which returns a url value which will be used in the GB_showCenter function. createGraph() is in the javascript and looks like this:
function createGraph(tag) {
var string = "";
var checkboxes = document.getElementsByName(tag+"-checkbox");
for(var i=0; i<checkboxes.length;i++){
if(checkboxes[i].checked){
if(string != "") string += "&";
string += checkboxes[i].getAttribute("class")+"="+checkboxes[i].value;
}
}
var url = location.href;
url = url.split("/");
url.pop();
var urlString = url.join("/");
urlString += "/graph.html?"+string;
return urlString;
}
originally I just had it returning
return "graph.html?"+string;
However, this did not work so I added the complex URL parsing approach above. It outputs the correct URL but I believe I’m running into problems where the browser thinks I’m running cross-domain when in fact all files are in the same directory on my computer.
What am I doing wrong? All I want to do is return a link to the graph.html page with the correct GET variables.
Thanks for your help.