On Jun 14, 10:15 am, Dimitris Papageorgiou <[email protected]>
wrote:
> I want to test a GetSelection code.
>
> The code is the following:
>
> function GetSelectedText () {
> if (window.getSelection) { // all browsers, except IE before
> version 9
var range = window.getSelection ();
// I assume you meant this statement to be on a separate line.
> alert (range.toString ());
> }}
> This code assumes that a text segment is selected in a webpage.
> The console seems that it does NOT communicate/interact with the webpage
> where it is opened.
I'm unsure what makes you say this.
>
> How am i going to validate the above code?
The code above is a function declaration. When you put it in the
console it evaluates to |undefined| because the expression has no
value.
>
> I wrote the code in the console, selected text from the webpage, pressed the
> run command and what i get is *undefined*.
I believe this is the correct result.
If you want to run the function you have to call it. For that you can
use:
GetSelectedText();
or
(function GetSelectedText () { if (window.getSelection)
{ var range = window.getSelection(); alert
(range.toString ()); } })();
jjb
>
> I do not think the code is wrong, it is just that the firebug console seems
> not to communicate with the webpage where it is opened.
> I am talking only for the console, no problem with css or html.
>
> Thanks.
--
You received this message because you are subscribed to the Google Groups
"Firebug" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/firebug?hl=en.