473,387 Members | 1,486 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,387 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 4618
"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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.