473,408 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Help sought for browser button

Hello group.

This is my first message in this group, and my first stab at
Javascript.

I am trying to tweak the code for the "FOLDOC button"
(http://foldoc.org/foldoc/tools.html) to be able to execute a DB query
over my firm's intra-net.

The source code for the IE button is as follows:

javascript:f=document.frames.length;q=(f?'':docume nt.selection.createRange().text);for(i=0;i<documen t.frames.length;i++){q=document.frames[i].document.selection.createRange().text;if(q!='')br eak;}if(q=='')void(q=prompt('search
foldoc:',''));if(q!=null){q='http://www.foldoc.org/?'+escape(q);void(f?open(q):window.location=q)}

which when reasonably indented looks like this:

javascript:
f=document.frames.length;
q=(f?'':document.selection.createRange().text);
for(i=0; i<document.frames.length; i++)
{
q=document.frames[i].document.selection.createRange().text;
if(q!='')
break;
}
if(q=='')
void(q=prompt('search foldoc:',''));
if(q!=null)
{
q='http://www.foldoc.org/?'+escape(q);
void(f?open(q):window.location=q)
}

For reasons I don't understand, IE *requires* that the entire code be
in one single line. Notwithstanding that, the FOLDOC button works
quite well.

My tweak to the FOLDOC code attempts to do this:
* In either the selected text, or the text entered in the 'Prompt'
box,
* Strip off all text EXCEPT,
* numbers of 5 or more digits.

For example, when a text such as

In v6.1.25.4 release, defects 12345, 23456, 78901 and 24211 were fixed
on 4/5/6. Docs are available at ftp://12.34.56.78/TR34251.txt

is selected (or copy-pasted), the string should be reduced to

12345,23456,78901,24211,34251

before appending it to my query URL.

My attempt is as follows (I have laid it out indented and spread out
although the IE button code has it all in one single line):

f=document.frames.length;
q=(f?'':document.selection.createRange().text);
for(i=0; i<f; i++)
{
q=document.frames[i].document.selection.createRange().text;
if(q!='')
break;
}
if(q=='')
void(q=prompt('Search for Defect ID:',''));
if(q!='' && q!=null)
{
q=q.replace(/\D+/g,'#');
q=q.replace(/\b\d{1,4}#/g,'#');
q=q.replace(/#+/g,',');
q=q.replace(/(^\,|\,$)/gm,'');
q='http://intranet.myfirm.com/query.asp?JTSNo='+escape(q);
}
else
q='http://intranet.myfirm.com';
void(f?open(q):window.location=q);

The problem is, when I click the button (for this code), NOTHING
happens.

Some observations:
* I use IE 6.0.2900 on XP SP2 (includes all current patches/security
fixes).
* I have UNCHECKED the "Disable script debugging" option as well as
CHECKED the "Display notification on every script error".
* I've tried installing Microsoft script debugger.
* The above code reduced to a single line is well within the 2083
character limit.

None of them have any effect, i.e., IE does not seem to think there is
any error. It simply just does not do anything.

The help I seek:
* Is there anything wrong with the code above? Is there any better way
to do what I have sought to do?
* Can anyone explain why nothing happens, yet another button with near
identical code works flawlessly?
* In general, how do I debug such code?

All advice/insights appreciated,
- Anand Hariharan

Feb 8 '06 #1
3 1431
VK

ma********************@gmail.com wrote:
For reasons I don't understand, IE *requires* that the entire code be
in one single line. Notwithstanding that, the FOLDOC button works
quite well.
javascript: pseudo-protocol is still *protocol* so should follow the
URL schema where line breaks are not allowed unless escaped.
q='http://intranet.myfirm.com/query.asp?JTSNo='+escape(q);
}
else
q='http://intranet.myfirm.com';
void(f?open(q):window.location=q);

The problem is, when I click the button (for this code), NOTHING
happens.

Some observations:
* I use IE 6.0.2900 on XP SP2 (includes all current patches/security
fixes).
* I have UNCHECKED the "Disable script debugging" option as well as
CHECKED the "Display notification on every script error".
* I've tried installing Microsoft script debugger.
* The above code reduced to a single line is well within the 2083
character limit.

None of them have any effect, i.e., IE does not seem to think there is
any error. It simply just does not do anything.

The help I seek:
* Is there anything wrong with the code above? Is there any better way
to do what I have sought to do?
* Can anyone explain why nothing happens, yet another button with near
identical code works flawlessly?
* In general, how do I debug such code?


Create a test page and place your code as a normal JavaScript function
(so line breaks between statements are OK). Call this function on
button click. Place alert() in different places (starting from the
function first line) to see where the execution breaks or even if it
starts at all.

Feb 8 '06 #2

VK wrote:
ma********************@gmail.com wrote:
For reasons I don't understand, IE *requires* that the entire code be
in one single line. Notwithstanding that, the FOLDOC button works
quite well.


javascript: pseudo-protocol is still *protocol* so should follow the
URL schema where line breaks are not allowed unless escaped.


Thanks for the response, VK.

If by 'escaping' you mean ending each line with a back-slash, tried
that and that does not work (IE reports invalid character).

Some observations:
* I use IE 6.0.2900 on XP SP2 (includes all current patches/security
fixes).
* I have UNCHECKED the "Disable script debugging" option as well as
CHECKED the "Display notification on every script error".
* I've tried installing Microsoft script debugger.
* The above code reduced to a single line is well within the 2083
character limit.

None of them have any effect, i.e., IE does not seem to think there is
any error. It simply just does not do anything.

The help I seek:
* Is there anything wrong with the code above? Is there any better way
to do what I have sought to do?
* Can anyone explain why nothing happens, yet another button with near
identical code works flawlessly?
* In general, how do I debug such code?


Create a test page and place your code as a normal JavaScript function
(so line breaks between statements are OK). Call this function on
button click. Place alert() in different places (starting from the
function first line) to see where the execution breaks or even if it
starts at all.


Like I said, I am new with Javascript, and I admit I do not know how to
"".

I did put alert at a number of places (even at the first line) - as I
said NOTHING happens (i.e., nothing gets executed ever).

However, when I removed the 'replace' calls, it works and has the
semantics of the FOLDOC button (i.e., whatever text entered or selected
is appended to the query). So, the code that I put in for
pre-processing the input seemingly causes some parse problems for IE?

NB: The code, the intention behind my pre-processing is all in my
original post. I can reproduce them again if you'd like.

best wishes,
- Anand

Feb 8 '06 #3

mailto.anand.hariha...@gmail.com wrote:
VK wrote:
ma********************@gmail.com wrote:

Create a test page and place your code as a normal JavaScript function
(so line breaks between statements are OK). Call this function on
button click. Place alert() in different places (starting from the
function first line) to see where the execution breaks or even if it
starts at all.


Like I said, I am new with Javascript, and I admit I do not know how to
"".


Sorry about that. I meant to say 'I do not know how to Call this
function on a button click'.

Feb 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: brendan | last post by:
Sorry this isnt a cross post .. i just didnt get any help from alt.php. I have a website which utilises post forms for navigation in some areas. Problem is, when *some* users hit the BACK button...
1
by: Jenny | last post by:
Need urgent help for an unsolved problem. In our ASP web application, we creat a Back button and if user click on this button, it execute history.go(-1) to go back to the previous page. All our...
8
by: DKM | last post by:
Here are the source code files to a Java applet that utilizes LiveConnect to communicate with Javascript, and the HTML file. The thing works both in IE 6.0 and FireFox 1.4. but with some...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
2
by: Steve K | last post by:
I got a bit of a problem I like some help on. I'm designing an online training module for people that work in food processing plants. This is my target audience. These workers have little or no...
8
by: pamelafluente | last post by:
I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work. This is what I need to accomplish: ---------------------- Given button and a TextBox on a...
0
by: toeffetommy | last post by:
Hello, I need a piece of functionality developed for our Website and I need some technical advice on how get there. Essentially, what I want to develop is a browser-within-browser...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
8
by: Richard Maher | last post by:
Hi, I am in a mouseup event for button A and I'd like to disable=false button B before starting some work. Is there anyway that an event for button B can then fire before my event processing for...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.