473,289 Members | 1,808 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,289 software developers and data experts.

Mouse shape after opening a new window and closing it

All,
I have a printer friendly page that is opened when a user clicks a link on
my page to get the printer friendly version,
How ever when they close out the printer friendly version and return to the
original page the mouse cursor is a Hour glass shape!
my code:

I use DIV tag
<DIV id ="printThis">
<%
response.write strTable
%>
</DIV>
<A HREF ="javascript:void(printFriendly())">Print This Page</A>

the javascript function printFriendly is:
function printFriendly()
{
if (document.getElementById != null)
{
var html = '<HTML>\n<HEAD>\n';
html += '\n</HEAD>\n<BODY>';
var printFriend = document.getElementById("printThis");
if (printFriend != null)
{
html += printFriend.innerHTML;
}
else
{
alert("Could not find any thing to print");
return;
}
html += '\n</BODY>\n</HTML>';
var printWin = window.open("","Printer Friendly");
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
}
else
{
alert("Sorry, the print ready feature is only available in modern
browsers.");
}
}
-->
</SCRIPT>

What I have seen is that the Mouse shape is effected after returning to the
original page Why? I am not sure but I have noticed that on some browsers
this does not happen and also in my browser the hour glass shape happened 8
out of ten time!

Any ideas why this may happen

Thanks
Jawahar
Jul 20 '05 #1
2 4615
"Jawahar Rajan" <jr****@nc.rr.com> wrote in message
news:Rd**********************@twister.southeast.rr .com...
<snip>
How ever when they close out the printer friendly version
and return to the original page the mouse cursor is a Hour
glass shape! my code: <snip> <A HREF ="javascript:void(printFriendly())">Print This Page</A>

<snip>

That is one of the many reasons for not using the javascript: pseudo
protocol:-

<URL: http://www.jibbering.com/faq/#FAQ4_24 >

Richard.
Jul 20 '05 #2
DU
Jawahar Rajan wrote:
All,
I have a printer friendly page that is opened when a user clicks a link on
my page to get the printer friendly version,
How ever when they close out the printer friendly version and return to the
original page the mouse cursor is a Hour glass shape!
my code:

I use DIV tag
<DIV id ="printThis">
<%
response.write strTable
%>
</DIV>
<A HREF ="javascript:void(printFriendly())">Print This Page</A>

For *many* reasons that I won't explicit here, do not use the
"javascript:" pseudo-protocol in a href value: that's bad, bound to go
wrong, create problems for the user.
the javascript function printFriendly is:
function printFriendly()
{
if (document.getElementById != null)
{
var html = '<HTML>\n<HEAD>\n';
html += '\n</HEAD>\n<BODY>';
You need to escape occurences of / & when constructing a string like that.
Your code is somewhat illogical. You interrogate if the user agent
supports the getElementById method and if it does, then why not go ahead
and try to construct that document with DOM level 1 and DOM level 2
methods for creating DOM nodes. I would expect you to resort to
document.write if the user agent would not support getElementById, not
the reverse.
var printFriend = document.getElementById("printThis");
if (printFriend != null)
This if control statement is somewhat redundant: you tested if the user
agent supports getElementById already, so your printFriend variable
should point to the referenced element "printThis". Here, you would
prefer to test the support for innerHTML if you want to use this.
{
html += printFriend.innerHTML;
}
else
{
alert("Could not find any thing to print");
return;
}
html += '\n</BODY>\n</HTML>';
Here, you need to escape the occurences of / within the constructed string:

html += '\n<\/BODY>\n<\/HTML>';

Here, I would watch the html var value with a debugger... just to make
sure of your code.
var printWin = window.open("","Printer Friendly");
The 2nd argument of the window.open() call requires a single string
without blank space.
Strangely enough, NS 6.2+ and Mozilla-based browsers are tolerant of
blank spaces in this 2nd argument of the open() call while MSIE 5+ is
not... but only the Netscape documentation explicitly indicate that
blank spaces are not allowed.

"windowName can contain only alphanumeric or underscore (_) characters."
http://devedge.netscape.com/library/...w.html#1202731

"When opening a window, this is a String that specifies the name of the
window."
http://msdn.microsoft.com/workshop/a...ods/open_1.asp

The single blank space in the "Printer Friendly" could be why you would
get an hour glass in MSIE 6.
printWin.document.open();
This could be related to bug 191377:
window.open("") does not open blank window
http://bugzilla.mozilla.org/show_bug.cgi?id=191377
http://bugzilla.mozilla.org/attachme...38&action=view

Apparently, loading a window and modifying a document tree are 2
different asynchronized processes. That's why sometimes scripts fail
because the WindowObjectReference.document.write() call can not be done
since the loading of the window (with its reference pointer, etc..) is
not completed yet. Overall, people underestimate or ignore the amount of
resources (parsing, rendering, RAM, cpu, video, etc..) required to
create a single new window, an ordinary popup window.

printWin.document.write(html);
printWin.document.close();
}
else
{
alert("Sorry, the print ready feature is only available in modern
browsers.");
}
Right here, you are confirming what I think. If the user agent is a
modern browser, then why not resort to DOM1 and DOM2 methods for
creating DOM nodes instead of document.write and innerHTML?
}
-->
</SCRIPT>

What I have seen is that the Mouse shape is effected after returning to the
original page Why?
The hourglass cursor means that the os is still busy doing something
important: sometimes, it indicates an infinite loop or a memory leak.

I am not sure but I have noticed that on some browsers

You did not say which browser and browser version does have the problem
you describe.
this does not happen and also in my browser the hour glass shape happened 8
out of ten time!

Any ideas why this may happen

Thanks
Jawahar


If we could see a fully coded page for testing, we could pinpoint the
problem. But in the meantime, I can offer 2 acceptable alternatives to
your given code.

1- use a print media stylesheet:
"CSS Beyond the Browser: Going to Print
Say no to 'printer-friendly' versions and yes to printer-specific style
sheets. CSS expert Eric Meyer shows how to conceive and design print
style sheets that automatically format web content for off-screen
delivery. Includes tips on hiding inappropriate content, styling text
for the printer, and displaying the URL of every link on the page."
http://www.alistapart.com/stories/goingtoprint/

2- use createElement() DOM level 1 methods and populate your document in
the popup that way.
E.g.:
http://bugzilla.mozilla.org/attachme...38&action=view

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

Jul 20 '05 #3

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

Similar topics

4
by: masantha wee | last post by:
Hi all, I am using Firefox and embedding Javascript in html. I understand that we can use mouse events by coding them in the body of html (by creating a button or anything and by adding in the...
6
by: lauren quantrell | last post by:
I have a command button on a continuous subform and I want the user to click it to open a small popup form that opens in the position of the mouse (which is the same as the position of the command...
2
by: KarenP | last post by:
In my Windows Forms application, while executing a process that takes some time, I am changing the cursor to the hourglass by setting Cursor.Current = Cursors.WaitCursor. This is working just...
2
by: Jim Frazer | last post by:
Hi, I'm working on an application in C# that will allow the user to create simple CAD drawings on a CEPC system. I would like to be able to change the cursor shape depending on the drawing mode...
0
by: lechatthierry | last post by:
Is it possible to block a mouse event on an Hyperlink with a general script event? This is quite troublesome for me. I am trying to find a way to block the windows shortcut SHIFT + MOUSE LEFT...
1
by: Neko | last post by:
Is it possible to block a mouse event on an Hyperlink with a general script event? This is quite troublesome for me. I am trying to find a way to block the windows shortcut SHIFT + MOUSE LEFT...
1
by: MrNobody | last post by:
I'm going to be creating shapes in a OnPaint method of an extended Panel object, and I need mouse event functionality (onClick, onMouseOver) that kind of stuff... what's the best way to go about...
4
by: cb.brite | last post by:
Hello, I have tried this using the MouseEnter/MouseLeave events. However these events do not really refer to the rectangular shape of the form, but the client area (form area minus children...
5
by: RomeoPapacy | last post by:
I'm currently writing a replacement shell and am suffering from quite dire memory leaks, when running, every time I roll my mouse over the taskbar icon a new window scrolls out revealing the window's...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

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.