Jump to content

hacknsack

Members
  • Posts

    183
  • Joined

  • Last visited

Everything posted by hacknsack

  1. OK, the reason it wouldn't work for "localhost", there was no mime type set for .xml or .xsl files. After I set the mime type the above code works both "locally"(no host) and with my localhost(Apache). I'll throw together a zip file and get it to you.
  2. Two questions:1) Which example illustrates what effect you're desiring?With JavaScriptJust HTMLWhat would you like for it to do?Do you want the user to be able to load a page when they click on a region?-or-Is the object just to give info regarding the image?
  3. boen_robot,Glad you posted because I need your expertise in solving the riddle:Why does the page work fine for me locally, but if I fire up Apache and use it as localhost -or- if I upload the files to a server Mozilla kicks up an error.Is there something wrong with the format of the xsl, is it the use of "transformToDocument()" .If the page is working well for your applications could you create a small zip file that I could study, I would appreciate it.The question about Opera, in my testing I've noticed that you can also grab the contentsof the files using responseText, would it be possible to write those to an iframe?I would appreciate your help with optimizing this.
  4. Please don't try this at home....What I mean is, I've just started studying XML and XSLT so anything in this post should be taken "as just that". In my searching, the IE flavor of the code seems pretty universal, surprised that I could only find one source of a working version for Mozillaharriot's postAll the source files came from:W3 Try It Page <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <title>First XML Data Import</title><script type="text/javascript">var sourceXML = 'cdList.xml';var sourceXSL = 'cdStyle.xsl';var xmlhttpXML, xmlhttpXSL, loadedStyle, loadedXML;function getIEXML(){ var writeObj = document.getElementById('xmlData'); // Load XML var xml = new ActiveXObject("Microsoft.XMLDOM"); xml.async = false; xml.load(sourceXML); // Load the XSL var xsl = new ActiveXObject("Microsoft.XMLDOM"); xsl.async = false xsl.load(sourceXSL); // Transform writeObj.innerHTML = xml.transformNode(xsl);} function startMozXML(){ // Load the XSL xmlhttpXSL = new XMLHttpRequest(); xmlhttpXSL.open("GET", sourceXSL, false); xmlhttpXSL.send(null); loadedStyle = xmlhttpXSL.responseXML; // Load the XML xmlhttpXML = new XMLHttpRequest(); xmlhttpXML.open("GET", sourceXML, false); xmlhttpXML.send(null); var xmlDoc = xmlhttpXML.responseXML; // Transform and display var writeObj = document.getElementById('xmlData'); var xsltProcessor = new XSLTProcessor(); var xmls = new XMLSerializer(); xsltProcessor.importStylesheet(loadedStyle); var xmlDoc = xsltProcessor.transformToDocument(xmlhttpXML.responseXML); writeObj.innerHTML = xmls.serializeToString(xmlDoc); }function init(){ // Test Browser's Support if(window.ActiveXObject){ getIEXML(); } else if(window.XMLHttpRequest && window.XSLTProcessor){ startMozXML(); } else { document.getElementById('xmlData'). innerHTML = 'No Support In This Browser..' }}window.onload = init;</script></head><body><div id="xmlData">Please Wait...</div></body></html> Tested in NN8, FF and IE6. (Edit: First testing locally, worked fine in all, later testing from server Mozilla fails)(Did find a good article Understanding XML.)(Edit 2: Fixed, I had no mime type set up in my Apache config)If nothing else maybe a start on "search terms".Good Luck,(Edit 3 (by Jonas): Changed to [CODEBOX])
  5. I would highly recommend that you get in the habit of using ";" at the end of your lines.One of the original problems was in the way you built your div content string.Also, you don't need 'if' with the Conditional Operatorhttp://www.w3schools.com/js/js_operators.aspAnother recommendation is to not re-write the innerHTML but just use the "style" properties "top" and "left" to move the object.And z-index: -1 kills it in Mozilla. <html> <head> <script type="text/javascript"> <!-- var y = 60; var x = 150; var ud = true; var lr = true; function scroll() { if(y > 600) ud = false; if(y < 0) ud = true; if(x > 700) lr = false; if(x < 0) lr = true; (ud == true)? y++ : y--; (lr == true)? x++ : x--; //alert(x + ' ' + y); document.getElementById('head').innerHTML= '<h1 style="position:absolute; left:' + x + 'px; top:' +(y)+ 'px; z-index: 1"><b>HELLO</b></h1>'; t = setTimeout('scroll()',20); } function scrollb() { document.getElementById('div2').style.top = x + 'px'; document.getElementById('div2').style.left = y + 'px'; t2 = setTimeout('scrollb()',20); } function init(){ scroll(); scrollb(); } window.onload = init; //--> </script> </head> <body> <div id="head"> </div> <div id="div2" style="position: absolute;"> Moving text without re-writing the innerHTML </div> </body></html> Let us know if you need more.Thanks,
  6. Well here's a shot at it, we might be able to tweak this toward your application. <?php$startTime = mktime(0, 0, 0, 1, 1, date('Y'));$now = time();$week = 7 * 24 * 60 * 60;$wkNumber = ceil(($now - $startTime)/$week);$cycle = ($wkNumber % 5);$randNumber = 0;echo "This is week number $wkNumber.<br>";echo "We are working with cycle number $cycle.<br>";function mkRand($lwrLimit, $uprLimit){ global $randNumber; $randNumber = mt_rand($lwrLimit, $uprLimit);}switch($cycle){ case 0: mkRand(1, 10); break; case 1: mkRand(11, 20); break; case 2: mkRand(21, 30); break; case 3: mkRand(31, 40); break; default: mkRand(41, 50); break; }echo "The random number is $randNumber"; ?> Did you want to display one unique out of a group of 10?-or-Did you want to display a group of 10 at the same time on the same page?Thanks,
  7. Glad it was helpful, , just happy to be of service.Thanks,
  8. You can capture that like this: <script type="text/javascript"> function getSel(){ var selObj = document.forms["f1"].elements["mod_options"]; alert(selObj.selectedIndex); alert(selObj.options[selObj.selectedIndex].value); } </script> </head> <body> <form name="f1"> <select name="mod_options" onchange="getSel()"> <option value="">Pick One</option> <option value="1">1</option> <option value="2">2</option> </select> </form> Thanks,
  9. Choco,I'm not sure if you are trying to disable the form or not, maybe an idea for you here..Also included example of how you can use "new RegExp()" to create the re. <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <title></title> <script type="text/javascript"> var word = 'test'; // \b looks for word boundary var re = new RegExp("\\b" + word + "\\b","gi"); alert(re); function chgForm(){ document.forms['REPLIER'].elements['submit'].onmouseover = ckPost; } function ckPost(){ var field = document.forms['REPLIER'].elements['Post']; var found = field.value.match(re); if(found){ alert('Word found in post..'); setTimeout("document.forms['REPLIER'].elements['Post'].focus();", 50); } } window.onload = chgForm; </script> </head> <body> <form name="REPLIER"> <textarea name="Post" rows="6" cols="20"></textarea> <input name="submit" type="submit"> </form> </body></html> Good Luck,
  10. How would you feel about a CSS solution?http://www.tanfa.co.uk/css/examples/rollov...-no-preload.aspUsing "hover".
  11. One thing you might consider is "preloading" the images. People on dial-up will havevery erratic action. Preloading will insure an instant swap.Nice work on your page.
  12. mani_,Kinda difficult to say without knowing your context, but here's what I think you mean.test.php <?phpecho "alert('".$_GET['user']."');";?> jsTest.html <html><head> <title>PHP Caller</title><script type="text/javascript" src="test.php?user=mani_"></script></head><body>This is a test....</body></html> Let me know if I'm not getting your meaning.Thanks,
  13. You'll need to post a url or your page source code.
  14. guleriahp,You can set a global variable and check it's state to execute your next code. <html><head> <title></title><script type="text/javascript">var go_next = false;//variable for our check cyclevar tm = null;function checkCond(){var form = document.forms["f"]; if(form.elements["e1"].value.toLowerCase() == 'go'){ // next line clears the check cycle clearInterval(tm); go_next = true; doForm(form); }}function init(){tm = setInterval('checkCond()', 800);setTimeout('ckNext()', 1000);}function ckNext(){ if(go_next){ alert('Everything is complete..'); } else { setTimeout('ckNext()', 1000); }}function doForm(form){ form.elements["e2"].value = 'OK';}window.onload = init;</script> </head><body><form name="f"> Go to start: <input type="text" name="e1"><br> Result: <input type="text" name="e2"></form></script></body></html> Get back to us if you have any questions.Thanks,
  15. Linne,Chocolate570 is dead on.This is what you can do with those links to stop that. <html><head> <title></title><script type="text/javascript">function MM_openBrWindow(URL,name,specs,replace) { //v2.0 window.open(URL,name,specs,replace);}</script></head><body><a href="http://w3schools.invisionzone.com/style_emoticons/default/smile.gif" onclick="MM_openBrWindow(this.href,'','width=681,height=515'); return false;"> Open Image</a></body></html> The "return false" makes it work like you want.Thanks,
  16. hmmmm,You must be in the fast learners program. <html><head> <title></title><script type="text/javascript">var swapObjs = new Array();var j = -1;var stop = false;function imgObj(src, title, tm){this._img = new Image();this._img.src = src;this.title = title;this.tm = tm;this.showImg = showImg;swapObjs[swapObjs.length] = this;}function showImg(){var imgObj = document.getElementById('img1');imgObj.src = this._img.src;}new imgObj('http://w3schools.invisionzone.com/style_emoticons/default/smile.gif', 'Happy', 1000);new imgObj('http://w3schools.invisionzone.com/style_emoticons/default/ohmy.gif', 'Happy', 1000);new imgObj('http://w3schools.invisionzone.com/style_emoticons/default/mellow.gif', 'Somber', 1000);new imgObj('http://w3schools.invisionzone.com/style_emoticons/default/dry.gif', 'Dry', 1000);function doStuff(){if(stop) return;(j == swapObjs.length - 1)? j = 0 : j++;swapObjs[j].showImg();setTimeout('doStuff()', swapObjs[j].tm);}window.onload = doStuff;</script></head><body><img id="img1" src="http://w3schools.invisionzone.com/style_emoticons/default/dry.gif" title="Dry" border="0" onmouseover="stop = true;" onmouseout="stop = false; doStuff();"></body></html> Pretty cool that you want to step on into methods and objects.And yes setTimeout only accepts a string as it's first argument.Please post back if you have any questions.Thanks,
  17. Now I can finally decode those haxxor strings with my handy decoder ring...
  18. deejaybet,To make this script compatible you just need to refer to your fields differently.http://webfeet.siteburg.com/haxxor.htmlThanks,P.S. You can check out the progress here if you like.http://webfeet.siteburg.com/myTester.html
  19. You're Welcome.. :)Glad you got it working.
  20. freshboy,You never want to use a "timer" function inside a loop(javascript anyway).The other problem with the code is that the only time "document.write()" canbe used is on the initial page load, any time after the page has loaded it destroysthe page and it's contents.You can use a couple of different methods like changing the innerHTML of an elementor you can create a container for the number and append it like this: <html><head> <title></title><style type="text/css">span { display: block; }</style> <script type="text/javascript">var x = 1;function mkLines(){if(x == 10) return;var oDiv = document.getElementById('d2');var nwSpan = document.createElement('span');var nwText = document.createTextNode(x++);nwSpan.appendChild(nwText);oDiv.appendChild(nwSpan);setTimeout('mkLines()', 1000);}window.onload = mkLines;</script> </head><body><div id="d2"></div></body></html> Thanks,
  21. real_illusions,The most common mistake is that a set of "script" tags is included in the external file.Make an external file like(test.js): alert('Our file just loaded..'); Put this inside your head or body tags: <script type="text/javascript" src="test.js"></script> The next most common mistake is not having a valid path to the external file.Thanks,
  22. How about adding an "ID" to the style link and then just alter the "href" value.(Each iframe source page would also have a style link with the same "ID")Tested this in IE6, FF, NN7, Op8.5 <html><head> <title></title><link id="sDef" href="ifStyle.css" rel="stylesheet" type="text/css"><script type="text/javascript">function loadStyle(styleSheet){var i_frames = document.getElementsByTagName('iframe');for(var k = 0; k < frames.length; k++){ frames[i_frames[k].name].document.getElementById('sDef').href = styleSheet; }document.getElementById('sDef').href = styleSheet;}</script> </head><body><div>You need bigger text.<form> <input type="button" value="Bigger Text" onclick="loadStyle('ifStyleB.css')"></form></div><iframe width="600" height="100" id="aFrame" name="aFrame" src="ifStyleA.html"> </iframe><iframe width="600" height="100" id="bFrame" name="bFrame" src="ifStyleA.html"> </iframe><iframe width="600" height="100" id="cFrame" name="cFrame" src="ifStyleA.html"> </iframe></body></html> Let me know if it doesn't test out OK for you.Thanks,
  23. hacknsack

    Free PHP Hosting

    This free host has worked very well for learning PHP and MySql.http://www.siteburg.com/Thanks,
  24. Thanks for letting us know that you got it worked out.Here's an example of what was proposed: <html><head> <title></title><style type="text/css">#A{ position: absolute; visibility: hidden; background-color: #80FFFF; } </style><script type="text/javascript">var sDiv = true;function toggle(){var oDiv = document.getElementById('A'); if(sDiv){ sDiv = false; oDiv.style.top = 15 oDiv.style.left = 60; oDiv.style.visibility = 'visible'; } else{ sDiv = true; oDiv.style.visibility = 'hidden'; }}</script></head><body><div>This is some test test. This is more test text.<br>This is some test test. This is more test text.<br>This is some test test. This is more test text.<br></div> <div id="A"> This is a div to toggle.<br> This is a div to toggle.<br> This is a div to toggle.<br> </div> <a href="javascript:toggle()">Toggle Div</a></body></html> Thanks,
  25. As far as I know you have to approach a radio set as an associative array.That means you'll need the element name. <script type="text/javascript"> function checkPets(cfield, s){ var fieldName = document.getElementById(s).name; var p = document.forms['f1'].elements[fieldName]; if(cfield.checked) { for(var i = 0; i < p.length; i++){ //remove the next line if you don't want them unchecked p[i].checked = false; p[i].disabled = true; } } else { for(var j = 0; j < p.length; j++){ p[j].disabled = false; } } } </script> </head> <body> <form name="f1"> <input type="radio" id="Kind" name="Pet" value="Cat"> Cat <br> <input type="radio" id="Kind" name="Pet" value="Dog"> Dog <br> <input type="radio" id="Kind" name="Pet" value="Snake"> Snake <br> <input type="checkbox" name="c1" onclick="checkPets(this, 'Kind')"> Don't Like Any Pets <b>Especially Snakes</b> </form> --Was that nice enough -- Shout back if you need more,
×
×
  • Create New...