Need help on search typed text with javascript

Forums » General Opera topics » User JavaScript

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

20. May 2010, 12:57:38

dude09

ex-Opera user

Posts: 5195

Need help on search typed text with javascript

Previously there is a JavaScript that allow me to search typed text without using clipboard content, but it's been broken since 10.5x... http://my.opera.com/community/forums/topic.dml?id=265522

Is there anyway to fix this JavaScript so that I can use it on 10.54?
Go to page, "javascript: window.open('http://www.answers.com/'+encodeURIComponent(document.selection.createRange().text)).blur();"


Thanks for any help. smile

20. May 2010, 17:12:29

Lex1

Posts: 1718

Replace
document.selection.createRange().text

on
function(){var d=document,s=d.getSelection(),t=d.querySelectorAll('textarea,input[type=\x22text\x22]');if(!s)for(var i=0,e;e=t[i];i++){if(s=e.value.substring(e.selectionStart,e.selectionEnd))break}return s}()

20. May 2010, 19:44:43

dude09

ex-Opera user

Posts: 5195

Oh WOW! Thanks. bigsmile

This changes has turn a simple JavaScript into a huge one... bigeyes
I wonder what did they changed in 10.5x that broke the previous script.

20. May 2010, 19:49:48

Lex1

Posts: 1718

I wonder what did they changed


http://my.opera.com/sitepatching/blog/2010/02/01/browser-js-for-10-5-the-giant-cleanup-2
«Removed - zhangmen.baidu.com textarea typing - we supported IE's document.selection object without full support for the IE selection APIs. This site (and some others) would detect document.selection and assume the entire API existed. In 10.5 we fix this by removing document.selection support.»

Forums » General Opera topics » User JavaScript