vForums Support Banner


Visit vForums

 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Programming Discussion :: IE = Facepalm - View Topic
Topic Rating: *****
Printable View
Marc
vChat Developer
*****
I <3 Rossy

Posts: 3,388
Status: Offline
Gender: Male
Location: Ontario, Canada
Age: 32
Joined:  

Additional Groups:
Coding Team
***


Reputation: 40%  


pmwww
IE = Facepalm (28th Apr 10 at 3:12pm UTC)
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... {Sad}

rroll.to— Shorten a link, rickroll your friends.
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: IE = Facepalm (28th Apr 10 at 3:15pm UTC)
Let us have a look? {Cheesy}
Nick
Very Senior Member
*****

[Avatar]

Posts: 3,013
Status: Offline
Gender: Male
Location: vForums
Age: 35
Joined:  
Reputation: 62%  


pmwww
Re: IE = Facepalm (28th Apr 10 at 4:37pm UTC)
^what he said! {Smile}

and I agree ms should drop ie or at least give us the choice to choose a default browser.
Marc
vChat Developer
*****
I <3 Rossy

Posts: 3,388
Status: Offline
Gender: Male
Location: Ontario, Canada
Age: 32
Joined:  

Additional Groups:
Coding Team
***


Reputation: 40%  


pmwww
Re: IE = Facepalm (28th Apr 10 at 9:23pm UTC)
 
^what he said! {Smile}

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. {Sad}

Code:
 
  1. function add_ubbc(sTag,eTag)
  2. {
  3.     var pBox = document.pForm.body;
  4.     pBox.focus();
  5.  
  6.     if(typeof(pBox.selectionStart) != "undefined")
  7.     {
  8.         if(pBox.value)
  9.         {
  10.             var before = pBox.value.substr(0, pBox.selectionStart);
  11.             var curr = pBox.value.substr(pBox.selectionStart, (pBox.selectionEnd - pBox.selectionStart));
  12.             var after = pBox.value.substr(pBox.selectionEnd);
  13.  
  14.             pBox.value = before + sTag + curr + eTag + after;
  15.         }
  16.         else
  17.         {
  18.             var before = pBox.innerHTML.substr(0, pBox.selectionStart);
  19.             var curr = pBox.innerHTML.substr(pBox.selectionStart, (pBox.selectionEnd - pBox.selectionStart));
  20.             var after = pBox.innerHTML.substr(pBox.selectionEnd);
  21.  
  22.             pBox.innerHTML = before + sTag + curr + eTag + after;
  23.         }
  24.     }
  25.     else
  26.     {
  27.         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.");
  28.         return;
  29.         if (window.getSelection)
  30.         {
  31.             if(pBox.value)
  32.             {
  33.                 pBox.value = pBox.value.replace(window.getSelection(), sTag + window.getSelection() + eTag);
  34.             }
  35.             else
  36.             {
  37.                 pBox.innerHTML = pBox.innerHTML.replace(window.getSelection(), sTag + window.getSelection() + eTag);
  38.             }
  39.         }
  40.         else if (document.getSelection)
  41.         {
  42.             if(pBox.value)
  43.             {
  44.                 pBox.value = pBox.value.replace(document.getSelection(), sTag + document.getSelection() + eTag);
  45.             }
  46.             else
  47.             {
  48.                 pBox.innerHTML = pBox.innerHTML.replace(document.getSelection(), sTag + document.getSelection() + eTag);
  49.             }
  50.         }
  51.         else if (document.selection)
  52.         {
  53.             if(pBox.value)
  54.             {
  55.                 pBox.value = pBox.value.replace(document.selection.createRange(), sTag + document.selection.createRange() + eTag);
  56.             }
  57.             else
  58.             {
  59.                 var nBox = document.createElement("textarea");
  60.                 nBox.name = "body";
  61.                 nBox.style.width = "400px";
  62.                 nBox.style.height = "150px";
  63.  
  64.                 nBox.innerHTML = pBox.innerHTML.replace(document.selection.createRange(), sTag + document.selection.createRange() + eTag);
  65.  
  66.                 document.getElementById("txtBody").removeChild(document.getElementById("txtBody").firstChild);
  67.                 document.getElementById("txtBody").appendChild(nBox);
  68.             }
  69.         }
  70.         else
  71.         {
  72.             return "";
  73.         }
  74.     }
  75.  
  76.     pBox.focus();
  77. }
 


EDIT: Rossy, the code tags are deleting half of my code? {Sad} (just quote the post if you wish to see the actual code for now)

EDIT 2: The smilies are also being weird. {Shocked}

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 {Tongue Out}

rroll.to— Shorten a link, rickroll your friends.
 Printable View

All times are GMT+0 :: The current time is 3:56pm
Page generated in 0.5178 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums