How to get HTML source when highlight text? My code works on IE - not FireFox - Help
When you run it on I.E, I use mouse to highlight the bold text "Highlight Me Now" and click button "Test" - I see the alert box "<B>Highlight Me Now</B>" .
But in FireFox browser, it shows the alert "Highlight Me Now" without tag <B></B>. How to make FireFox grab the HTML tag <B></B> like the way IE browser did?
Here is my code
var selection = document.selection;
var newRng = selection.createRange();
var html_selection = document.getSelection();
<p><b>Highlight Me Now</b></p>
<input onclick="GETSELECTION();" type="button" value="Test">
Last edited by kevin31; 02-19-2007 at 12:54 PM.
I'm experiencing the same frustrations, except with my code, I'm not outputting the result of the getSelection to an alert box. The reason you're getting only the text in FF is explained here
Simply put, alerts are only meant to receive Straight text.. :-\
Also, for firefox you should probably use window.getSelection instead of document.getSelection as that method is deprecated.
Last edited by datdesignguy; 07-15-2007 at 12:27 AM.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)