Jump to content

Jesdisciple

Members
  • Posts

    822
  • Joined

  • Last visited

Everything posted by Jesdisciple

  1. I've never done it myself, but I've paid attention to others interested. You need to use a textarea for the HTML, to capture keyboard events. Then you lay an iframe over the textarea via CSS. When the user edits the textarea (which they don't know is there), you clean the HTML up and put it in the iframe. (Accessing the iframe's document involves a small but rather complicated technique, at least AFAIK.)
  2. Looks like it's not remotely cross-browser to me... http://www.google.com/search?hl=en&q=c...ditable+mozilla
  3. I did try it, although I haven't read it yet. (I'm probably not familiar enough with JQuery to make sense of it.) I did notice that the Link button replaces my selection with "undefined" rather than wrapping it.I can't seem to find the thread with either the forum's search or Google, but someone suggested recently that an XML document be used to keep track of a WYSIWYG's HTML. This would help abstract tasks like finding an italic element within an italic element (italic.getElementsByTagName('i')), finding adjacent italic elements and fusing them, and unwrapping an element.BTW, I hope you know that you're not really using CSS? That's also possible, and might be a better practice even though the style can't be separated from the layout in this case. But it would make the XML DOM approach more complicated.
  4. I'm a nitwit; I didn't keep the frame after looking its ID up, so I was making properties on a string. The simplest bugs are often the most formidable. (And a fresh look is often their only solution.) <html> <body> <iframe id="frame" src="about:blank"></iframe> <script type="text/javascript"> function loopFrame(frame, steps, delay){ if(typeof frame === 'string') frame = document.getElementById(frame); if(typeof delay !== 'number') delay = 10000; var i = 0; iterate(); function iterate() { if(i < steps.length){ if(typeof steps[i] === 'string') steps[i] = new Step(steps[i], delay); setTimeout(function (){ alert(steps[i].url); frame.onload = function (){ alert(''); }; frame.src = steps[i].url; i++; iterate(); }, steps[i].delay); } } } function Step(url, delay){ this.url = url; this.delay = delay; } var steps = ["http://www.google.com/", "http://www.yahoo.com/", "http://www.msn.com/", new Step("http://www.good.com/", 16000), new Step("http://www.bad.com/", 16000)]; loopFrame('frame', steps); </script> </body></html>
  5. My bad... I just found my stupid mistake. Use the lone slash as your path and replace the last code box (for test1.html and test2.html) with this one: <html> <head> <title>Titled Document</title> <script type="text/javascript" src="Cookie.js"></script> <script type="text/javascript"> var cookie = new Cookie('back'); (function (){ // will execute immediately var limit = 10; var back = parseInt(cookie.get()); if(!isNaN(back)) if(back < limit){ cookie.set(back + 1); history.back(); }else cookie.erase(); })(); </script> </head> <body> <a href="test1.html">Test 1</a> <a href="test2.html">Test 2</a> <a id="back">To go back, click your browser's "Back" button.</a> <script type="text/javascript"> Element.prototype.on = function (action, response, capturing){ var listener = 'on' + action; this[listener] = response; var w3c = 'addEventListener'; var ie = 'attachEvent'; if(typeof this[w3c] === 'function') this[w3c](action, response, !!capturing); else if(typeof this[ie] === 'function') this[ie](listener, response); }; (function (){ // will execute immediately var back = document.getElementById('back'); back.on('click', function(event){ cookie.set(0); history.back(); return false; }); back.innerHTML = 'Go back.'; back.href = '#back'; })(); </script> </body></html>
  6. The code I posted in the other thread is still broken, but I found a workaround. If you know the folder which the HTML pages are contained in, you can attach all cookies to that folder. It's not as easy as it would ideally be, but it works. In the code below, replace /to/HTML/ with your path. Do not include any domain; the beginning slash specifies the root directory and no domain is present in the path which is causing the problems.Cookie.js function Cookie(name, value, days){ this.name = name; if(typeof value !== 'undefined') this.set(value, days);}Cookie.prototype = { set: function (value, days){ if(days){ var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); }else var expires = ""; document.cookie = this.name + '=' + value + expires + '; path=/to/HTML/'; }, get: function (){ var nameEQ = this.name + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) === ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; }, erase: function (){ this.set('', -1); }}; main page <html> <head> <title>Titled Document</title> <script type="text/javascript" src="Cookie.js"></script> <script type="text/javascript"> (function (){ // will execute immediately var cookie = new Cookie('back'); if(cookie.get() !== null) cookie.erase(); })(); </script> </head> <body> <a href="test1.html">Test 1</a> <a href="test2.html">Test 2</a> </body></html> test1.html and test2.html <html> <head> <title>Titled Document</title> <script type="text/javascript" src="Cookie.js"></script> <script type="text/javascript"> (function (){ // will execute immediately var limit = 10; var cookie = new Cookie('back'); var back = parseInt(cookie.get()); if(!isNaN(back)) if(back < limit){ cookie.set(back + 1); history.back(); }else cookie.erase(); })(); </script> </head> <body> <a href="test1.html">Test 1</a> <a href="test2.html">Test 2</a> <a id="back">To go back, click your browser's "Back" button.</a> <script type="text/javascript"> Element.prototype.on = function (action, response, capturing){ var listener = 'on' + action; this[listener] = response; var w3c = 'addEventListener'; var ie = 'attachEvent'; if(typeof this[w3c] === 'function') this[w3c](action, response, !!capturing); else if(typeof this[ie] === 'function') this[ie](listener, response); }; (function (){ // will execute immediately var back = document.getElementById('back'); back.on('click', function(event){ document.cookie = 'back=0;'; history.back(); return false; }); back.innerHTML = 'Go back.'; back.href = '#back'; })(); </script> </body></html>
  7. That's a very weird bug. I wish I had tested while building that version, but it's too late now. Do you want to work on it with me?
  8. Ignore what I said about the else block; I was thinking of my intermediate structure. Notice that, while I named the iterate function (and it's a good thing because now I need to reference it twice), I'm passing this new function directly to setTimeout - just because I'm not sure what to name it. I'm also not assigning the return value to a variable because I don't need to clear the timeout.Also, if you keep refusing to try, that will make my purpose impossible and helping won't be worth my time. <html> <body> <iframe id="frame" src="about:blank"></iframe> <script type="text/javascript"> function loopFrame(frame, steps, delay){ if(typeof frame === 'string') document.getElementById(frame); if(typeof delay !== 'number') delay = 10000; var i = 0; iterate(); function iterate() { if(i < addresses.length){ if(typeof steps[i] === 'string') steps[i] = new Step(steps[i], delay); setTimeout(function (){ frame.src = steps[i].url; i++; iterate(); }, steps[i].delay); } } } function Step(url, delay){ this.url = url; this.delay = delay; } var steps = ["http://www.google.com/", "http://www.yahoo.com/", "http://www.msn.com/", new Step("http://www.good.com/", 16000), new Step("http://www.bad.com/", 16000)]; loopFrame('frame', steps); </script> </body></html>
  9. On the last call to iterate (in an else block), set a 16-second timeout for a function A. Inside A, change the iframe's URL and set a 19-second timeout for another function B. Inside B, change the iframe's URL.I want you to try again before I give any more effort. For me, the purpose of this thread is that you gradually learn to code on your own.
  10. That's the best answer in the absence of PHP, although I hope we don't run into this problem again. (And I would think this e-commerce website would have the shopping cart already set up server-side...)
  11. JS shouldn't be used if it's not needed. The target attribute is by far more widely recognized than JS. (Plus inline event handlers are poor practice.)
  12. The background for this problem is at this other thread. I made a Cookie class based on http://www.quirksmode.org/js/cookies.html and included it on three pages. My problem is that after the "Go back." link is clicked all other pages redirect to index.html even though I've tried to erase all cookies. The culprit seems to be the cookie which uses the current directory as its path despite the instruction to use the server's document root. I can't figure out why some cookies obey and others don't. (I even tried setting the paths of all cookies to ./ but that's not translated to the current directory.) I've experienced this behavior in Firefox and Opera. Konquerer creates the misbehaving cookie when I click "Go back." but doesn't obey history.back. Any ideas?Cookie.js function Cookie(name, value, days){ this.name = name; if(typeof value !== 'undefined') this.set(value, days);}Cookie.prototype = { set: function (value, days){ if(days){ var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); }else var expires = ""; document.cookie = this.name + '=' + value + expires + '; path=/'; }, get: function (){ var nameEQ = this.name + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) === ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; }, erase: function (){ this.set('', -1); }}; index.html <html> <head> <title>Titled Document</title> <script type="text/javascript" src="Cookie.js"></script> <script type="text/javascript"> (function (){ // will execute immediately var cookie = new Cookie('back'); if(cookie.get() !== null) cookie.erase(); })(); </script> </head> <body> <a href="test1.html">Test 1</a> <a href="test2.html">Test 2</a> </body></html> test1.html and test2.html <html> <head> <title>Titled Document</title> <script type="text/javascript" src="Cookie.js"></script> <script type="text/javascript"> (function (){ // will execute immediately var limit = 10; var cookie = new Cookie('back'); var back = parseInt(cookie.get()); if(!isNaN(back)) if(back < limit){ cookie.set(back + 1); history.back(); }else cookie.erase(); })(); </script> </head> <body> <a href="test1.html">Test 1</a> <a href="test2.html">Test 2</a> <a id="back">To go back, click your browser's "Back" button.</a> <script type="text/javascript"> Element.prototype.on = function (action, response, capturing){ var listener = 'on' + action; this[listener] = response; var w3c = 'addEventListener'; var ie = 'attachEvent'; if(typeof this[w3c] === 'function') this[w3c](action, response, !!capturing); else if(typeof this[ie] === 'function') this[ie](listener, response); }; (function (){ // will execute immediately var back = document.getElementById('back'); back.on('click', function(event){ document.cookie = 'back=0;'; history.back(); return false; }); back.innerHTML = 'Go back.'; back.href = '#back'; })(); </script> </body></html>
  13. The actual URLs in the history are concealed for privacy reasons. I tried to implement a cross-page document.cookie loop to go back until either the correct page was found or a certain number of links had been gone back over, but one cookie always refused to be deleted and that broke all forward links (because each page already visited always sent me back to the "correct" page after the loop had been executed). I think it should work, and I'm going to ask about it.
  14. What DOCTYPE are you using? If it's not Strict, you can use target="xyz" and "xyz" will always refer to the same window.http://learningtheworld.eu/2007/xhtml-with-target/http://www.accessify.com/features/tutorials/new-windows/
  15. If the user is refreshing the cart by clicking links, each linked page will be in the browser's history; if they're clicking the Refresh button, the Back button will send them one link back. I know of no reliable way to alter this behavior.BTW, I didn't mean to sound curt in my last post; I was in a rush and needed to call attention to that quote.
  16. Oh, this is related to the other... So what should trigger the client-side script to change the total?
  17. You can also specify a limit in preg_split, which might be faster than two calls to strpos and one to explode. $str_array = preg_split('/\/ [<>]/', $str, 2);
  18. Is IE the only browser which it's not working in right now? What's the latest version which works in IE? Could you explain the "limiter" in more detail? When does text wrap twice? Why does it matter? Why would you need to remove a wrap? (Am I understanding what a wrap is?) When should tags be removed? EDIT: http://w3schools.invisionzone.com/index.php?showtopic=19434
  19. When do you expect this script to run? If it's a server-side script, why not just go ahead and add to cart?
  20. Do you have any questions regarding that?
  21. Neither am I a security expert; that's why I advise every reasonable precaution. I can't think of any situation where having includes in a web-accessible directory might compromise security. However, I know that's one entirely unnecessary step closer to insecurity (unless you're on shared hosting, and then you still have .htaccess to do almost the same thing as hidden directories).
×
×
  • Create New...