clonetrooper9494 Posted January 26, 2008 Share Posted January 26, 2008 For some reason, this is just not working!!! I am trying to make a simple 'include on every page thing' by putting a code of JavaScript on every page, but this just is not working no matter what I do! no error messages, nothing at all! Arg I just want to throw my computer out my window(even though it has nothing to do with it)Here is the code: <html><head><title></title></head><body oncontextmenu="return movemenu()" onclick='movemenuback()'>test<textarea style="display:none" id="addon"></tr></td><tr><td><hr width="90%"></td></tr><tr></textarea><textarea style="display:none" id="extra"></textarea><script>var x = '0';var y = '0';function show_coords(e){ e = (e) ? e : window.event; x = e.clientX; y = e.clientY;}document.onmousemove = show_coords;function movemenu(){document.getElementById('menu').style.left = x + 'px';document.getElementById('menu').style.top = y + 'px';return false}function movemenuback(){document.getElementById('menu').style.left = '-100px';document.getElementById('menu').style.top = '-100px';}var t = document.getElementById('extra').value;var p = document.getElementById('addon').value;if(t == ''){var write_in = '';}else{var write_in = p + t;}var abc = "<div id=\"menu\" style=\"position:absolute;top:-100;left:-100;display:block;\"><table border='1' bgcolor='EEEEEE' bordercolor='BBBBBB' style=\"border-collapse: collapse;\"><tr><td><table border='0' bgcolor='EEEEEE' bordercolor='BBBBBB'><tr><td onmouseover=\"this.style.backgroundColor = '#BBBBBB'\" onmouseout=\"this.style.backgroundColor = '#EEEEEE'\" style='background-color:EEEEEE;' onclick=\" window.location='http://clone-drone.net'\">Home</tr></td><tr><td onmouseover=\"this.style.backgroundColor = '#BBBBBB'\" onmouseout=\"this.style.backgroundColor = '#EEEEEE'\" style='background-color:EEEEEE;' onclick=\" window.location='http://clone-drone.net'\">Games</tr></td><tr><td onmouseover=\"this.style.backgroundColor = '#BBBBBB'\" onmouseout=\"this.style.backgroundColor = '#EEEEEE'\" style='background-color:EEEEEE;' onclick=\" window.location='http://cmail.clone-drone.net'\">Clone-Mail" + write_in + "</tr></td></table></tr></td></table></div>";document.write(abc)</script></body></html> Here is the link:http://www.clone-drone.net/ajax_test.html Link to comment Share on other sites More sharing options...
Ingolme Posted January 26, 2008 Share Posted January 26, 2008 Well, the most important problem here is this:var abc = "<div id=\"menu\" style=\"position:absolute;top:-100;left:-100;display:block;\"><table ...You can't insert a line break within a line of Javascript code.You can use \n or escape them with \.Like this:var abc = "\n<div id=\"menu\" style=\"position:absolute;top:-100;left:-100;display:block;\">\<table ... Link to comment Share on other sites More sharing options...
clonetrooper9494 Posted January 26, 2008 Author Share Posted January 26, 2008 so, I have to make it like this?? ...: var abc = "<div id=\"menu\" style=\"position:absolute;top:-100;left:-100;display:block;\">\n<table border='1' bgcolor='EEEEEE' bordercolor='BBBBBB' style=\"border-collapse: collapse;\">\n<tr><td>\n<table border='0' bgcolor='EEEEEE' bordercolor='BBBBBB'>\n<tr><td onmouseover=\"this.style.backgroundColor = '#BBBBBB'\" onmouseout=\"this.style.backgroundColor = '#EEEEEE'\" style='background-color:EEEEEE;' onclick=\" window.location='http://clone-drone.net'\">\n\nHome\n\n</tr></td><tr><td onmouseover=\"this.style.backgroundColor = '#BBBBBB'\" onmouseout=\"this.style.backgroundColor = '#EEEEEE'\" style='background-color:EEEEEE;' onclick=\" window.location='http://clone-drone.net'\">\n\nGames\n ECT. Does everything have to be on the same line like up there? Link to comment Share on other sites More sharing options...
Ingolme Posted January 26, 2008 Share Posted January 26, 2008 Either all on the same line, or you escape the line breaks by putting a \ at the end.But again, why are you trying to generate all that HTML instead of just wtiting it right there? Link to comment Share on other sites More sharing options...
clonetrooper9494 Posted January 26, 2008 Author Share Posted January 26, 2008 Ok, I need it to be like this: <html><head></head><body oncontextmenu="return movemenu()" onclick='movemenuback()'><script src="the code above"></script></body></html> I want to include it on every page... without having too much other junk, and so if I make a major change, I don't have to go through every file making that change! Link to comment Share on other sites More sharing options...
Ingolme Posted January 26, 2008 Share Posted January 26, 2008 Are you sure you're not able to use a server-side language to do that? Link to comment Share on other sites More sharing options...
clonetrooper9494 Posted January 26, 2008 Author Share Posted January 26, 2008 That would make every page on my site .php ... is there a way to make your site excute PHP if it was .html? I know some sites that are .phtml , does that mean I could try and edit something to do that?I already have the PHP to do it in another file... Link to comment Share on other sites More sharing options...
Ingolme Posted January 26, 2008 Share Posted January 26, 2008 Well, there's nothing wrong with a .php extension to the file. It still should read the HTML just fine, only it executes the PHP too. Link to comment Share on other sites More sharing options...
clonetrooper9494 Posted January 26, 2008 Author Share Posted January 26, 2008 ok, thanks, I guess I will be stuck with PHP then...Thanks everyone! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.