JavaScript - Display Message New Page
javascript2.js
Code: function displayMessage(msg) { // Open a new window var msgWindow = window.open('', 'Message'); // Write message in the new Window msgWindow.document.write(msg); // Raise this window, in case it's not visible msgWindow.focus(); } //Enter total number of questions: var totalquestions=13 var correctchoices=new Array("a","a","b","c","b","c","a","a","b","c","a","b","b"); var correctanswers=new Array("memory locations","_ underscore","x=5+5;","20","Else","lose win","ticker = ticker + 1;","Ticker = ticker + 1;","300.000","Jonathon \b","var","var counter;","var mark = 50, 70"); function gradeit(){ var actualchoices=new Array() var msg1=new Array() var correctanswersno=0 var t=0 var displaycorrectanswers="" for (q=1;q<=totalquestions;q++){ var thequestion=eval("document.Questionform.q"+q) for (c=0;c<thequestion.length;c++){ if (thequestion[c].checked==true) actualchoices[q]=thequestion[c].value } if (actualchoices[q]==correctchoices[q]){ msg1[t]=q+")"+" Correct"; correctanswersno = correctanswersno + 1; t = t + 1; } else { msg1[t]=q+")"+" Incorrect: <br>Correct Answer: "+correctchoices[q]+") "+correctanswers[q]; t = t + 1; } } for (p=0;p<=12;p++){ displaycorrectanswers+="<br>"+msg1[p]; } var msg="Sco "+correctanswersno+"/"+totalquestions+" <br><br>Marks: "+displaycorrectanswers; displayMessage(msg); } Basically on my index page it has a button which when clicked makes use of gradeit(). Currently this then used displayMessage(msg) which opens a new window and displays the message. However, what I want it to do is to open another created html page e.g. answer.html and then for this page to display the message. How do i do this? Similar TutorialsHi, I have php script that uploads a file. once i click upload it should display a animated GIF image or "Loading please wait" message with the backround transparent screen covering the whole page so that the user is not able to click anything during file upload. How can i do this? Could someone help me on this. Thanks in advance. Hi, I am a newbie in JS, and have already been stuck with this problem for the whole day. Basically I want to display a var returned from a function with <fmt:message/> tag. It sounds easy, but somehow I just can't get it to be display correctly (Tried with alert() and it worked). Here is my code: ------------------------------------------------------------------------------------------- <script> function ReturnTime() { var dateobj=new Date(); if (dateobj.getSeconds()%30==0) { return dateobj.getSeconds(); } else { return dateobj.getSeconds(); } } time1 = ShowTime(); alert(time1); </script> <fmt:message key='content.currentTime'/>: <cut value="${time1}"/> ------------------------------------------------------------------------------------------------------------------------- I might have done some stupid things here. But I am very new to JS (2 days of experience so far). So please be patient. Your kind help will be very much appreciated. Regards, Robert Hi guys im trying to give users a warning message with javascript when the submit my login form without inserting any new data. But I can't seem to find out how to stop the form from going to the login.php here is my code. Code: <form name="te" onsubmit='login();' action='login.php' method='post'> <input name='username' maxlength='14' value='Username' type='text' /> <input name='password' maxlength='20' value='Password' type='password' /> <input type="submit" name="login" value="Login" /> </form> javascript: Code: <script type="text/javascript"> function login() { var username = document.te.username.value; var password = document.te.password.value; if (username == 'Username' || username == '') { alert('empty username!'); return false; } else { if (password == 'Password' || password == '') { alert('empty pass'); return false; } } return true; } </script> How Do I Put An Error Message In This Age vervication htm page Below? ---------------------------------------------------------------------- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="shortcut icon" href="http://cdn.battlefieldbadcompany2.com//misc/favicon.ico" type="image/x-icon"> <link type="text/css" rel="stylesheet" media="all" href="./agegate_files/css_2b22bb76f86419edef5093a148bae2d9.css"> <link type="text/css" rel="stylesheet" media="print" href="./agegate_files/css_d34ed7daed866afd03ff14a52c469b82.css"> <!--[if IE]> <link type="text/css" rel="stylesheet" media="all" href="http://battlefieldbadcompany2.com/sites/all/themes/zen_ninesixty/css/ie.css?D" /> <![endif]--> <script type="text/javascript" src="./agegate_files/js_07d74692b8bac063e891abbaba65653e.js"></script> <script type="text/javascript"> <!--//--><![CDATA[//><!-- jQuery.extend(Drupal.settings, { "basePath": "/", "thickbox": { "close": "Close", "next": "Next \x3e", "prev": "\x3c Prev", "esc_key": "", "next_close": "Next / Close on last", "image_count": "Image !current of !total" } }); //--><!]]> </script> </head> <body class=" agegate"> <div id="wrapper"> <div id="page" class="container-12"> <div id="site-header"> <div id="header-inner" class="grid-12"> </div> </div> <!-- End 'site-header' --> <div class="agegate-block"> <div class="agegate-header"> <h2>Enter your age</h2> </div> <div class="content"> <img src='enterage.gif' /> <form action="./agegate_files/agegate.htm" accept-charset="UTF-8" method="post" id="agegate-form" class="agegate-form"> <div><div class="languages"><h3>Country ( US ONLY )</h3><div class="flag-wrapper"><div><ul> <li class="en"> <a class="active" href="agegate.htm"> <img height="20" width="36" title="English" alt="English" class="language-icon" src="./agegate_files/en.gif"> </a> </li> </ul></div></div></div><div class="form-item" id="edit-age-wrapper"> <input type="text" maxlength="2" name="age" id="edit-age" size="2" value="" class="form-text agegate-age-input"> </div> <div class="form-item"><a href='index.htm'><input type="submit" name="op" id="edit-submit" value="Continue" class="form-submit agegate-submit-btn"></a> </div><input type="hidden" name="form_build_id" id="form-6167175a48bd92c722f6decc9d1c5ac7" value="form-6167175a48bd92c722f6decc9d1c5ac7"> <input type="hidden" name="form_id" id="edit-agegate-form" value="agegate_form"> </div></form> </div> </div> </div> <!-- End 'page' --> </div> <!-- End 'wrapper' --> <div id="omnitureWrapper" style="display: none;"><script language="javascript" src="./agegate_files/utils.js"></script> <script language="JavaScript"><!-- var language = "en"; omniture="home"; var country = ""; var category = ""; var host = ""; switch(language) { case "en": country = "us"; category = "NA"; language = "en-US"; host = "eaeacom,eaeacomna,eaeabrandna,eagamebfbc2na,eagamebfbc2global"; break; case "en-gb": country = "uk"; category = "EMEA"; language = "en-GB"; host = "eaeacom,eaeacomeu,eagamesuk,eagamebfbc2uk,eagamebfbc2global"; break; default: country = "us"; category = "NA"; language = "en-US"; host = "eaeacom,eaeacomna,eaeabrandna,eagamebfbc2na,eagamebfbc2global"; break; } var s_account=omniCheckHost(host) var s_imageDisableFlag = 0; //--></script> <script type="text/javascript" language="JavaScript" src="./agegate_files/s_code_remote_v02.js"></script> <script language="JavaScript"><!-- s_ea.server="" s_ea.channel="" s_ea.prop1=s_ea.setUserState('No ID') s_ea.prop2="BFBC2" s_ea.prop3="GAMES" s_ea.prop4="BATTLEFIELD" s_ea.prop5= "BFBC2"; s_ea.prop7= "DICE"; s_ea.prop9= "MKT"; s_ea.prop10= "Agegate"; s_ea.prop11= category; s_ea.prop12= language; s_ea.prop15= "General Info"; s_ea.prop17= country.toUpperCase(); s_ea.prop18= country.toUpperCase()+":BFBC2"; s_ea.pageName=category+":"+country.toUpperCase()+":"+s_ea.prop3+":"+s_ea.prop7+":"+s_ea.prop9+":"+s_ ea.prop4+":"+s_ea.prop2+":"+s_ea.prop5+":"+s_ea.prop10.toUpperCase(); /* E-commerce Variables */ s_ea.eVar1="No ID"; s_ea.eVar3="BFBC2"; s_ea.eVar17=country.toUpperCase(); s_ea.eVar18=category ; s_ea.eVar29=s_ea.setInitValOnce(country.toUpperCase()+":"+s_ea.prop2+":"+s_ea.prop5); s_ea.eVar30=country.toUpperCase()+":"+s_ea.prop2+":"+s_ea.prop5; s_ea.eVar34="GAMES";/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/ if((s_imageDisableFlag == null) || (typeof (s_imageDisableFlag) == "undefined") || (!s_imageDisableFlag)){var s_code=s_ea.t();if(s_code)document.write(s_code);}//--></script><!-- End SiteCatalyst code version: H.0. --><script language="javascript" type="text/javascript" src="./agegate_files/omniture_wrapper.js"></script></div> </body></html> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="Content-Style-Type" content="text/css"><meta http-equiv="Content-Script-Type" content="text/javascript"><script type="text/javascript">function sendV(f){location.href='https://sandbox.google.com/checkout/api/checkout/v2/checkoutForm/Merchant/' +f['id'].value +'?' +f['item_name_1'].name+'='+f['item_name_1'].value + '&' +f['item_description_1'].name+'='+f['item_description_1'].value + '&'+f['item_quantity_1'].name+'='+f['item_quantity_1'].value + '&' +f['item_price_1'].name+'='+f['item_price_1'].value;;}</script></head><body><form action="POST"> <input type="text" name="id"><input type="hidden" name="item_name_1" value="Peanut Butter"/><br/> <!-- Product Description --><i>Chunky peanut butter</i><input type="hidden" name="item_description_1" value="Chunky peanut butter."/><br/> <!-- Quantity --><input type="hidden" name="item_quantity_1" value="1"/> <!-- Unit Price -->Price: $<input type="text" name="item_price_1"/><br/> <!-- charset=UTF-8; Do not remove this line --><input type="hidden" name="_charset_"/> <input name="sub" value="Send value" type="button" onclick="sendV(this.form)"></form></body></html>---End Quote---
Hell All Can some1 give me a function for Alert Visitor before the page Load if he /she Sure wants to See the Page . I have function Onclick alert message but i want the function is when click and go to the page and before the page load to ask 'if want realy to see the page' if yes return true if cancel or no to go back to where he come from. Thank you and hope such function exist. Hi, I have dozens of pages on my website which have just started showing an 'Error on page' message at the bottom left of Internet Explorer 8.0. These messages do not appear when using Mozilla Firefox. My website is www.lakesandcumbria.com and an example of a page showing the error message is http://www.lakesandcumbria.com/view/walks/ambleside.htm which contains a javascript drop down list. All other pages using this type of drop down list are showing the same error message (dozens of them). I have ensured that 'Script debugging' is disabled in Internet Explorer but this hasn't helped! Help - How can I stop this happening in Internet Explorer 8.0 please? how i can refresh my main history page without page refresh alert message? i am using the following code on the submitpage.asp <%response.write ("<script>window.location.reload(history.go(-2));</script>")%> i got the attached message when it refreshes the main page. is there is a way to refresh directly without this message? Hi, I am Aditya. I am explaining below the exact scenario where I need the help: I am developing a web application in which I need to integrate a javascript/html editor on some of the web pages and then provide 'Edit' buttons on those web pages so that users can edit the content on that partciular html/jsp page (like editing in wiki pages) and then, when they add some content and click on submit button, the new content should appear on the web page with all the formatting (i.e. bold, italics, color and so on) which was applied by user when he was entering the text. Now, I need help for the below issues: 1. Please suggest me a good javascript/html editor (freely downloadable) which I can use to integrate with my web pages. 2. Once the user has entered some content using the above javascript editor, how to make that content reach the server and update the corresponding web page. I am new to web development, so may be that these questions are too simple. But, I need some help from you. Waiting for your reply, Thanks, Aditya Hi there! I am using GlassBox "http://www.glassbox-js.com/" As a light box on a website. Basically, You click an thumbnail image, and a window pops up with a larger version of that image. Now originally, the window opened X number of pixels from the top of the page. However, My thumbnail images were located mid page, so when you clicked on one, the window would open at the top of the page and the user would not see it unless they scrolled up. So I attempted to modify the script so that it would get the users page width/height and display it directly in the center no matter the position. Now my problem is that the script only works when the user has already scrolled down. So if the page is scrolled all the way to the top, and you click on a thumbnail, the window will not open center screen. Here is an example: http://synaxis.pcriot.com/ When the page loads, DO NOT scroll it, and click on the image. You will see the window pop up, and not centered, like it should be. However, now if you scroll down, and click the image again, you see that it is now centered. I also noticed that when the page is scrolled up, and the image does not center, it always is placed below the thumbnail image, or otherwise where ever the DIV is located. It normally located under the image, but if i place the DIV at the top of the page then the window will pop up there. And this does happen on every browser that I have tested, Firefox, IE, and Chrome. So, I am pretty much stumped as to why this is happening. If anyone can shed some light I would be very grateful. Thank You Here is a link to the original code: http://synaxis.pcriot.com/javascript...ox/glassbox.js And modified code: http://synaxis.pcriot.com/javascript...ox/glassbox.js The modified code is at the very bottom of the script. Original Code: Code: /** * @public */ if ( typeof($) == 'undefined' ) { $ = function (id) { return document.getElementById(id); } } Modified Code Code: /** * @private */ var removeElement = function(id) { var Node = document.getElementById(id); Node.parentNode.removeChild(Node); } /** * @private */ var getDocHeight = function() { var db = document.body; var ddE = document.documentElement; return Math.max( db.scrollHeight, db.offsetHeight, db.clientHeight, ddE.scrollHeight, ddE.offsetHeight, ddE.clientHeight ); } /** * @public */ if ( typeof($) == 'undefined' ) { $ = function (id) { return document.getElementById(id); } } Hi All, Im new to this forum...need some of your help and advice. I have a js code like this : <script type="text/javascript"> <!-- var sipPos = 0; $(document).ready(function() { $("#panel-tab").click(function(e) { //if(autoTimer) clearTimeout(autoTimer); //autoTimer = null; e.preventDefault(); $("#panel").animate({ left: sipPos }, 1764, 'linear', function() { if(sipPos == 0) { sipPos = -856; } else { sipPos = 0; } }); }); }); --> </script> what it does is that it hide and show a panel by slidint it to the left. But my client want that on page load the panel opens automatically for about 2-3 seconds just to let users know that its here. So ive written this : <script type="text/javascript"> <!-- var sipPos = 0; $(document).ready(function() { var autoTimer = null; autoTimer = setTimeout(function(){ $("#panel").animate({ left: sipPos }); autoTimer = setTimeout(function(){ $("#panel").animate({ left: sipPos = -856 }); }, 2000); },1000); $("#panel-tab").click(function(e) { //if(autoTimer) clearTimeout(autoTimer); //autoTimer = null; e.preventDefault(); $("#panel").animate({ left: sipPos }, 1764, 'linear', function() { if(sipPos == 0) { sipPos = -856; } else { sipPos = 0; } }); }); }); --> </script> But when the panel finished showing the button to open it again doesn't work...any help please..really urgent. thks //Sam Hi There, I am attempting to do a site which is of a similar format to a TV listings website. Each day's schedule will be on a different HTM page (contained within an iFrame), and I would like it to display the current day's schedule on the appropriate day. I have searched the forum, but can't find anything exactly like this (maybe I'm searching for the wrong thing), so any answers greatly appreciated. Thanks, Roz Currently the page has some divs' displays set to none. When a user clicks an anchored link, it displays the appropriate div. Here is the script I'm currently using, which works fine: Code: function showApp(whichApp) { document.getElementById('dTips').style.display='none'; document.getElementById('dCaseStudies').style.display='none'; document.getElementById('dWebinars').style.display='none'; document.getElementById('dReports').style.display='none'; document.getElementById('dDigimags').style.display='none'; document.getElementById('dPodcasts').style.display='none'; document.getElementById('dNews').style.display='none'; document.getElementById('dCalendar').style.display='none'; if (document.getElementById) { document.getElementById(whichApp).style.display='block'; } } Here's how I call it within the page: Code: <a href="javascript:showApp('dTips')">Tips</a> Is there any way to modify it so that if the user clicks a link on a different page, it goes to the APPS page and displays the requested div? If not, is there another way to accomplish this task? Hi. I am pretty sure this requires js, but if not and I am posting in the wrong section, I am sorry. Let me try to explain my situation so you know what i'm trying to accomplish. I am hosting a site on a home pc. My isp blocks inbound port 80 so I use no-ip services and port 80 redirect and cloak the address because it displays my ip instead of the domain name. For example, without the cloak it will show http://xxx.xxx.xxx.xxx:81/index.php instead of http://mydomain.com/index.php I would like to display the current page the user is on somewhere on the page. Example: You are currently viewing index.php How would I be able to accomplish this? When I hit the submit button, the result are display on a new page. how do I force it to stay on the same page, here's my code. Code: <HTML> <HEAD> <TITLE>Test Input</TITLE> <script type="text/javascript"> function addtext() { var newtext = document.myform.inputbox.value; document.writeln(newtext); } </script> </HEAD> <BODY> <FORM NAME="myform">Enter something in the box: <BR> <INPUT TYPE="text" NAME="inputbox" VALUE=""> <INPUT TYPE="button" NAME="button" Value="Check" onClick="addtext()"> </FORM> </BODY> </HTML> any comments or suggestions would be greatly appreciated. Hello, I have an issue. I can't seem to extract XML from an somepage.xml document and display it on a regular webpage. I have no way of reading its contents. I read up on some microsoft way of doing it, but not sure that is gonna fly (need it for most browsers), so can this be done easily with json/ajax? I have an xml file in normal format: www.somedomain.com/somepath/somexml.xml <products> <items> <item>blah</item> <item>blah2</item> <item>blah3</item> <item>blah4</item> <item>blah5</item> </items> </products> So, how do I get that data to manipulate and display in my html? I don't even know where to begin with json/ajx etc.. and how to call the xml file etc.. I know that when you "display: none" with CSS it will not show the div content in the browser, but will still show the div and content in page source. Is there a way (via javascript or anything else) to also remove the content from page source at the same time? Thanks. I have an iFrame that is loaded when a user types a url into a text box. Is it possible to display the meta-description of the page that is diplayed in the iFrame in the main (parent) page ? Here is the Iframe code I am using in the body: Code: <iframe src="http://www.mhgoebel.com" frameborder="0" id="frame" width="320" height="356" scrolling="no"> </iframe> and here is the script in the header: Code: <script> function goTo() { var input = get("box").value, frame = get("frame"); if(input.match(/\bhttp(.)*/)) { frame.src = input; } else { input = "http://" + input; frame.src = input; } } function get(id) { return document.getElementById(id); } </script> Bit of a noob when it comes to js. Hope someone can help me out. I am trying to place text output from a url on another webpage. The output is the status of an alarm system. The URL is: Code: https://www.eye-zon.com/EZMOBILE/index.php?mid=<hash>&action=ssi&did=<mac> hash and mac info remove for security reasons. The URL leads to a webpage that outputs: Code: <update>2011-08-18 21:21:10</update><status> Stay Armed </status><trouble>NO</trouble> I would like to place these three outputs on another page. Any ideas? Hi, i will try to be as brief as possible. I have a page A with form: Code: <form id="search" action="find.html" method="get"> ... (some select options) ... <input type="submit" class="submit" value="search"> this form look up some holiday destination which appears on this page with url: (example) Code: www.domain.com/find.html?destination=italy&price=500 Now, I dont want to display result on this page, but on page B, in iframe. I found a way how to redirect output as a link to properly show in iframe on page B. Page A contains: Code: <a href="pageb.html?http://www.domain.com/find.html?destination=italy&price=500">show on page B</a><br> Page B contains: Code: <script type="text/javascript"> <!-- function loadIframe(){ if (location.search.length > 0){ url = unescape(location.search.substring(1)) window.frames["iframe"].location=url } } onload=loadIframe //--> </script> <iframe src="" name="iframe" id="iframe"</iframe> In this case page B will properly load requested link in iframe. Problem is it is just a static link... I want to display search result from the form. Thanks a lot for your help... |