GEEK Is there any way to print a Web page without clipping the text on long lines? GEEK I assume that you have developed a Web page where, when you print the page out, the rendered width of the page appears to be larger than the printable area of the paper and long lines of text get chopped off. This same situation can occur when pages are viewed in a browser. Text that is too wide would be cut off on the sides, except the browser provides a scrollbar that lets the reader scroll back and forth to see all of the text. Unfortunately, until the new "electronic paper" stuff becomes readily available, there isn't any way to provide scrolling on a paper printout. Basically, the page you have designed is wider than the paper on which you want to output it. When a Web page is printed out, it is essentially rerendered to a surface the width of the printable area of the paper and isn't associated directly with the current width of the screen at all. Just because the page fits on the screen doesn't mean it is going to fit onto the paper. Usually, this problem is due to fixed-width tables or graphical elements on the page that are forcing a minimum size at which the page can be rendered without also displaying scroll bars on the window. There are two ways around this problem. You can either design your pages to be sizable to a narrower width that will allow proper printing, or you can print out the pages in landscape mode instead of portrait mode. Eventually Cascading Style Sheets (CSS) will allow Web page designers to embed printer switching options, such as landscape and portrait, directly into the Web page itself. That feature hasn't been added yet, so at the moment there isn't any way for the author to force the printer into landscape modeonly the user can do that.
GEEK I'm a student working on my thesis. I would like to use Visual Basic® to develop an electronic interface for a device that communicates via the printer port. How do I manipulate the outgoing individual bits of data? Could you recommend code samples that do what I've just described?
GEEK I'm learning about letting visitors customize Web sites using cookies (for user and preference detection). What if
the visitor has cookies disabled at the client side? In this case the entire site's content would be messed up. Is there any way
of detecting whether cookies are enabled? Besides using cookies, what other techniques are suitable for automated user/client detection? |
|
If the user has cookies enabled and the value for this cookie had been previously set to indicate a preference, then your page will be able to appropriately extract this value and assign the proper color value. However, the value of bgcolor might not be available because either the session belongs to a new user who never specified a color preference, or the user does not have cookies enabled on his system. Your page code simply needs to be prepared to check for these possibilities. But getting back to your scenario, providing the capability for the user to customize their view of your pages is a lot easier to deal with than other cookie concepts might be. The best solution would be to store a unique user account number in the cookie on the client side, then look up this user number in a database on your server to determine the settings that the user might have indicated in a previous visit to your site. Your code might look something like: |
|
On all subsequent pages, if you see a userid of "000000" then you know that the user just hasn't created an account yet. But if there isn't a value set for userid, then you know that the user does not have cookies enabled in his browser. How you choose to handle these two situations is completely up to you. If you want to create a site solution that can use cookies when they are available, but can also provide the same level of user customization when cookies aren't available, you will need to rely on some form of server-side management of user identification. Since, by design, Web pages are supposed to be free from any state information of this nature, there is no direct method for providing this capability built into the HTTP data transfer process. Each individual page is intended to live all by itself. However, various techniques have been devised to get around this. The easiest technique would be to mangle the URL with which the user accesses the site and embed a unique userid into the URL itself by appending it to the end of the address, as I did in this URL: http://www.genericserver.com/somepage.asp?userid=123456. If all the links on the page are coded to automatically embed the userid in this fashion, then you have a trackable userid throughout your site. |
From the January 2000 issue of Microsoft Internet Developer.
|