14. juni 2001 - 21:26Der er
4 kommentarer og 1 løsning
Problem med åbning af nyt vindue (javascript)
Jeg har et akut problem med et javascript. Der skal åbne et nyt vindue når link vælges i denne form: (det skal lige bemærkes at hvis jeg laver et link undefor formen men bare på siden, er der ikke noget problem-er nedenståenden nok? Siden vises i frames og derfor skal jeg markere target=_self for at få det til at virke som almindeligt link. men dette virker ikke i formen... PLEASE HJÆLP
<tr> <td width=\"100%\" colspan=\"2\"><FORM method=\"post\" action=\"test.asp\" name=\"\" target=\"_self\"> <SELECT name=\"go\" onChange=\"jumppage(this);\" size=1> <OPTION value=\"-\">Select an Option</OPTION> <OPTION value=\"java script:NewWin1()\">I want to order a product/service online</OPTION> <OPTION value=\"java script:NewWin2()\">I have an interest in/issue with an Chameleon product</OPTION> <OPTION value=\"java script:NewWin3()\">I have an interest in/issue with an Chameleon service</OPTION> <OPTION value=\"java script:NewWin4()\">I have questions/comments about the Chameleon website</OPTION> </SELECT> </FORM> </td> </tr>
<body topmargin=\"0\" leftmargin=\"0\" link=\"#CC3333\" vlink=\"#CC3333\" alink=\"#CC3333\"> <table border=\"0\" width=\"741\" cellspacing=\"0\" cellpadding=\"0\" height=\"1\" align=\"left\"> <tr> <td width=\"146\" bgcolor=\"#CC3333\" bordercolor=\"#BF5351\" height=\"1\"> <p align=\"right\"><font face=\"Times New Roman\"> <font color=\"#FFFFFF\" size=\"2\"><b>CONTACT US </b></font></font></td> <td width=\"41\" height=\"1\" rowspan=\"6\" valign=\"top\"> <p> </td> <td width=\"548\" height=\"21\"></td> </tr> <tr> <td width=\"146\" class=\"format\" bordercolor=\"#BF5351\" bgcolor=\"#CC3333\" height=\"1\" valign=\"top\"> </td> <td width=\"548\" rowspan=\"5\" valign=\"top\" height=\"1\"> <table border=\"0\" width=\"99%\"> <tr> <td width=\"100%\"> <table border=\"0\" width=\"100%\"> <tr> <td width=\"100%\" colspan=\"2\"> <dl> <dt><b><font face=\"Times New Roman\" size=\"4\">Contact </font></b><b><font face=\"Times New Roman\" size=\"4\">us</font></b></dt> </dl> </td> </tr> <tr> <td width=\"100%\" colspan=\"2\"><font size=\"2\" face=\"Times New Roman\">Should you wish to contact our office by mail, telephone or fax, the office information is provided below. If you have a question or feedback about Chameleon or our web site, please let us know.</font> <h4>Contact Chameleon Directly</h4> What is your <b>interest</b> in Chameleon?</td> </tr> <tr> <td width=\"100%\" colspan=\"2\"><FORM method=\"post\" action=\"test.asp\" name=\"\" target=\"_self\"> <SELECT name=\"go\" onChange=\"jumppage(this);\" size=1> <OPTION value=\"-\">Select an Option</OPTION> <OPTION value=\"/contact/orderform1.asp\">I want to order a product/service online</OPTION> <OPTION value=\"/contact/product1.html\">I have an interest in/issue with an Chameleon product</OPTION> <OPTION value=\"/contact/service1.asp\">I have an interest in/issue with an Chameleon service</OPTION> <OPTION value=\"java script:NewWin1()\">I have questions/comments about the Chameleon website</OPTION> </SELECT> </FORM> </td> </tr> <tr> <td width=\"10%\"></td> <td width=\"90%\"></td> </tr> <tr> <td width=\"10%\"></td> <td width=\"90%\"><a href=\"java script:NewWin1()\" target=\"_self\"><b><font face=\"Times New Roman\" size=\"3\">Feedback or questions in general</font></b></a></td> </tr> <tr> <td width=\"10%\"></td> <td width=\"90%\"></td> </tr> <tr> <td width=\"100%\" colspan=\"2\"></td> </tr> <tr> <td width=\"100%\" colspan=\"2\"><font face=\"Times New Roman\" size=\"2\">We are committed to maintaining your privacy during your visit to Chameleon.dk: By submitting this information, you consent to us using it as described above and sharing it within our company for these purposes. </font> <p><font face=\"Times New Roman\" size=\"2\"> To read about our privacy practices, please visit our <a href=\"/contact/privacy.html\" target=\"_self\"><b> Privacy Statement</b></a>. </font><br> <font face=\"Times New Roman\" size=\"2\">Because of the open nature of the Internet, we recommend you not submit information you consider confidential.</font></td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td width=\"146\" class=\"format\" bordercolor=\"#BF5351\" bgcolor=\"#CC3333\" height=\"1\" valign=\"top\"> <p style=\"margin-left: 10\"><b><font color=\"#C0C0C0\" face=\"Times New Roman\" size=\"1\"><a href=\"terms.html\" target=\"_self\">TERMS OF USE</a></font></b></p> </td> </tr> <tr> <td width=\"146\" class=\"format\" bordercolor=\"#BF5351\" bgcolor=\"#CC3333\" height=\"1\" valign=\"top\"> <p style=\"margin-left: 10\"><b><font color=\"#C0C0C0\" face=\"Times New Roman\" size=\"1\"><a href=\"privacy.html\" target=\"_self\">PRIVACY STATEMENT</a></font></b></p> </td> </tr> <tr> <td width=\"146\" class=\"format\" bordercolor=\"#BF5351\" bgcolor=\"#CC3333\" height=\"1\"> <p style=\"margin-left: 10\"> </p> </td> </tr> <tr> <td width=\"146\" class=\"format\" bgcolor=\"#676767\" height=\"1\" valign=\"top\"> <img src=\"../products/sidebar-profile.gif\" border=\"0\" width=\"146\" height=\"185\"> <table border=\"0\" width=\"100%\"> <tr> <td width=\"100%\"> <table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"> <tr> </tr> <b></b> </table>
ikke så underligt. i det første angiver du en url der skal loades ind i siden. I den sidste er det noget javascript detr skal udføres.
skriv din funktion jumppage om til:
function jumppage(sel) { var i = sel.selectedIndex; var val = sel.options[i].value; var forsteBogstav = val.substr(0,1); // foerste bogstav i value var resten = val.substring(1); // resten af value if ( forsteBogstav == \"0\" ) { // skal ignoreres // ignorer klik på allerførste option \"Select an Option\" } else if ( forsteBogstav == \"1\" ) { // hop til relativ url top.location.href = resten; } else if ( forsteBogstav == \"2\" ) { // javascript der skal udføres eval( resten ); }; }
og læg så et \"kodeciffer\" ind forrest i hver optionvalue altefter hvad det er for en slags value:
<SELECT name=\"go\" onChange=\"jumppage(this);\" size=1> <OPTION value=\"0-\">Select an Option</OPTION> <OPTION value=\"1/contact/orderform1.asp\">I want to order a product/service online</OPTION> <OPTION value=\"1/contact/product1.html\">I have an interest in/issue with an Chameleon product</OPTION> <OPTION value=\"1/contact/service1.asp\">I have an interest in/issue with an Chameleon service</OPTION> <OPTION value=\"2NewWin1()\">I have questions/comments about the Chameleon website</OPTION> </SELECT>
Jeg vil anbefale at du \"rydder op\" i siden. Der er en gevaldig masse script der ikke bruges til nogetsomhelst.
Hej JacobA - det virkede - Takker - endnu engang skulle du redde mig
Med venlig hilsen
Kenneth
Hvis du har tid ville jeg sætte stor pris på om du ville kigge forbi dette spørgsmål som ridder mig som en mare... http://www.eksperten.dk/spm/81056
Måske du kunne komme med et fornuftigt bud
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.