Jump to content

Jesdisciple

Members
  • Content Count

    822
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Jesdisciple

  • Rank
    Invested Member
  • Birthday 05/17/1989

Previous Fields

  • Languages
    HTML, CSS, JS, PHP, MySQL

Contact Methods

  • AIM
    Jesdisciple
  • MSN
    a_God_job@hotmail.com
  • Website URL
    http://jesdisciple.110mb.com
  • ICQ
    0

Profile Information

  • Location
    Texas
  • Interests
    apologetics & theology, programming, philosophy, bicycling, games
  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.)
×
×
  • Create New...