Thursday, October 22, 2009

Detect with Behaviors opportunely browser

We know, webpage browser arrives to return the standard with uniform neither one for this at present, created very handsome in a kind of browser page thereby, and ulterly changed however in that kind of browser phenomenon, appear to reduce this kind of phenomenon, we often should design same content according to a few kinds of browsers of the mainstream the webpage of different pattern. Have in domestic IE at present have absolutely rate, the webpage that below this kind of circumstance we design wants only compatible it went, but NetScape is in abroad or a lot of people are used, after all the patriarch that she is a browser. The webpage that Dreamweaver3 is designed for us and debugs different browser offerred a lot of convenience, about this I have special introducing additionally. So designed the webpage that suits different browser when us, how to detect automatically again does the browser of caller show different webpage thereby? This problem looks more complex. But the Check Browser act that uses Behaviors can be solved easily. Before using this method, you must prepare the page of 3 same content, suit IE browser (set for IEpage.htm) ; Suit NetScape browser (set for NSpage.htm) ; Another suit other browser (set for Otherpage.htm) . We explain specific method below:
1, considering country is major is IE browser, so we put Check Browser action on the webpage that suits IE browser. So we open this webpage in Dreamweaver3 (IEpage.htm) . When because we hope to be able to be in,be record in a webpage can detect automatically the browser opens corresponding page automatically, think of naturally to use " OnLoad " will spark incident, but Behaviors is used " OnLoad " spark this incident is conditional, this is told at the back of I put the article, be solved first with method of the same old stuff. Choose a few characters to become an empty link, press face plate of F8 v Behaviors again, click on face plate " + " icon, choose Check Brows er action in the menu that pulls next, shoot the Check Browser dialog box that give following plan institute show:

Graph 1 Check Browser touchs oppose word draw a frame round

At first view edits the window this so multi-parameter, still have a lot of option, not nervous, did the principle that understands this act to need not fear, this action is completed by a group of complex condition statements, make a choice according to the result of judgement, choose between 3 webpages firstly. This movement can judge two kinds of browsers clearly: Netscape and IE, not be entirely of these two kinds of browsers does Other Browser processing. Browser of judgement avery kind of can have 3 kinds of option, go To URL (open appoint a file) , go To Alt URL (open another appoint a page) , stay On This Page (stay in this page) . Definition Go To URL and place of Go To Alt URL point to a page URL and Alt URL.
2, so specific how should fill these parameter? We should make cle ar our purpose above all before choosing parameter, the result that we hope is: If IE browser is current page; If NetScape browser opens NSpage.htm; If not be,open Otherpage.htm. Should fill so so: That triangle icon is clicked in the input casing of the right side of Internet Explorer4.0 Or Later, choose " Stay On This Page " ; That triangle icon is clicked in the input casing of the right side of Netscape Navigator4.0 Or Later, choose " Go To URL " ; That triangle icon is clicked in the input casing of Other Browsers the right side, choose " Go To URL " ; NSpage.htm is filled in URL; Otherpage.htm is filled in Alt URL. Return Behaviors face plate by OK. Of course, you also can need those who use other to fill parameter method according to yours, additional, the file browser that also can click its right in the webpage file name of URL and Alt URL goes searching, after finding, choose directly go, differ want a hand to use an input surely. But a bit want to notice: Your Che ck Browser behavior should be added in the page of Stay On This Page, cannot have effect otherwise.
3, open window of source code postmortem, the code that we see empty link is medium is such:
<A Href="#" OnClick="MM_checkBrowser(4.0, 0, 2, 4, 1, 2, 2, 'bhjq1.htm' , 'bhjq2.htm');return Document.MM_returnValue" >
In mark moving after we cut that paragraph of intermediate code that calls a movement, and " OnClick " instead " OnLoad " , and delete that empty link. Meet when be record in this webpage so detect automatically the browser of the user opens the webpage of different pattern automatically according to different browser, be extremely clever! So complex issue cannot think of to be solved so simply.
If you are to just began to make this webpage or the blank part that can find a page, need not use become empty link, and order blank part directly, set Check Browses action next by face plate of F8 v Behaviors, the operation of after this and above identical, have in the face plate of Behaviors so " OnLoad " spark incident. The blank that what special attention wants here is a page is in and not be the blank that wait handles layer or form, will do not have otherwise " OnLoad " spark incident incident chooses for you. Because we discharge the webpage after good edition to seek blank office commonly,compare difficulty, so I am emphasized introduced the alternative above.

No comments:

Post a Comment