So, I was working on one of my sites yesterday, and decided to add UBBC buttons to the posting page. I began this project at about 11am. By noon, it was working nicely in FF/Chrome/Opera/Safari; even had an image uploader / advanced link maker in it.
Then...IE.
Let's just say by 5pm I had given up. Pretty much, the problem is that it keeps giving me "Unknown Runtime" errors whenever I try to use "innerHTML =" ("+=" works fine, though), forcing me to use DOM (which, funny enough, IE also doesn't do properly, and as such it's STILL not working).
Oh, and did I mention that I'm using "innerHTML = " a few hundred other times throughout the site with no issues?
*Sigh* I really wish Microsoft would just give up on the whole web browser thing and ship Firefox with Windows...![]()
Let us have a look?![]()
^what he said!![]()
and I agree ms should drop ie or at least give us the choice to choose a default browser.
^what he said!![]()
and I agree ms should drop ie or at least give us the choice to choose a default browser.
They do (at least for the past few months) give the option, but the problem is most users who aren't very tech-savvy will be too wary of using a different browser when IE works fine for what they use the internet for.
Oh, and here's how my code ended up after hours and hours of war with IE...it might make your eyes bleed, but again, IE's fault; it used to be pretty.![]()
Code:
- function add_ubbc(sTag,eTag)
- {
- var pBox = document.pForm.body;
- pBox.focus();
- if(typeof(pBox.selectionStart) != "undefined")
- {
- if(pBox.value)
- {
- var before = pBox.value.substr(0, pBox.selectionStart);
- var curr = pBox.value.substr(pBox.selectionStart, (pBox.selectionEnd - pBox.selectionStart));
- var after = pBox.value.substr(pBox.selectionEnd);
- pBox.value = before + sTag + curr + eTag + after;
- }
- else
- {
- var before = pBox.innerHTML.substr(0, pBox.selectionStart);
- var curr = pBox.innerHTML.substr(pBox.selectionStart, (pBox.selectionEnd - pBox.selectionStart));
- var after = pBox.innerHTML.substr(pBox.selectionEnd);
- pBox.innerHTML = before + sTag + curr + eTag + after;
- }
- }
- else
- {
- alert("Internet Explorer is stupid.\r\nI spent 6 hours trying to get this to work right, but IE won\'t play along.\r\nSo I\'ll get these working later.\r\nThe last 2 buttons work, though.");
- return;
- if (window.getSelection)
- {
- if(pBox.value)
- {
- pBox.value = pBox.value.replace(window.getSelection(), sTag + window.getSelection() + eTag);
- }
- else
- {
- pBox.innerHTML = pBox.innerHTML.replace(window.getSelection(), sTag + window.getSelection() + eTag);
- }
- }
- else if (document.getSelection)
- {
- if(pBox.value)
- {
- pBox.value = pBox.value.replace(document.getSelection(), sTag + document.getSelection() + eTag);
- }
- else
- {
- pBox.innerHTML = pBox.innerHTML.replace(document.getSelection(), sTag + document.getSelection() + eTag);
- }
- }
- else if (document.selection)
- {
- if(pBox.value)
- {
- pBox.value = pBox.value.replace(document.selection.createRange(), sTag + document.selection.createRange() + eTag);
- }
- else
- {
- var nBox = document.createElement("textarea");
- nBox.name = "body";
- nBox.style.width = "400px";
- nBox.style.height = "150px";
- nBox.innerHTML = pBox.innerHTML.replace(document.selection.createRange(), sTag + document.selection.createRange() + eTag);
- document.getElementById("txtBody").removeChild(document.getElementById("txtBody").firstChild);
- document.getElementById("txtBody").appendChild(nBox);
- }
- }
- else
- {
- return "";
- }
- }
- pBox.focus();
- }
EDIT: Rossy, the code tags are deleting half of my code?(just quote the post if you wish to see the actual code for now)
EDIT 2: The smilies are also being weird.![]()
Edit 3 by Ross: Not the code tags fault. More just the templating system. Have put in a fix so the message contents don't get run through it![]()