JavaScript - Noob In Need Of Some Quick Javascript Help Please
I am working on a site for an online radio station and I want an external player to launch on site visit and to continue playing as the visitors surf my site.
I feel I am 95% there as I have the player spawning on launch and checking for popup blockers. If a popup blocker is found the user is prompted to add my domain to their allowed lists so that future visits will launch the player right out of the box. My problem is this. When someone navigates back to the "home" page (where the script is located the external player window reloads and I do not want it to. I have found a couple of sites that say do this and that but I am a 100% novice at javascript and can not figure it out. here is the url of the site I am building http://www.radiotrips.com/czmradio - If you have popup blocker on you should get an alert. If not a small player should launch here is the code that I am using to spawn the external player and check for popup blockers ************** <script language="javascript" type="text/javascript"> function detectPopupBlocker() { var czmTest = window.open("http://www.radiotrips.com/czmradio/player/mini/no_ads.html","Cozumel Radio","width=478,height=260"); if (!czmTest) { alert("We were unable to automatically open the Cozumel Radio Player due to your pop-up blocker... Please add CozumelRadio.net to your allowed sites for your best listening experience"); } else { window.open("http://www.radiotrips.com/czmradio/player/mini/no_ads.html","Cozumel Radio","width=478,height=260"); } } ************** if anyone could add the code that would make the browser check to see if this window is already open and if so not reload it I would GREATLY appreciate it. I feel like it is 1 to 2 lines of code max according to what I have seen elsewhere but just cant figure it out. Thanks a Million in advance Chris Similar TutorialsI tried posting this: <button type="button" onclick="JavaScript:alert('Let's assume.....')"> <img src="question.jpg" alt="Click here" /> <br />Click for Answer!</button> and it shows the button with the picture, but I am unable to click it. Can you please help me? Thank you in advance. Hey guys I'm new to Javascript and need some help with this code Code: <HTML> <HEAD> <TITLE>Swap Test</TITLE> </HEAD> <BODY> <script type="text/javascript"> var numberOne; var numberTwo; // Declaring the values of numberOne and numberTwo var numberOne = 9; var numberTwo = 1; // Variables are swapped numberOne = numberTwo; numberTwo = numberOne; // Output is displayed on-screen document.write (numberOne); document.write (numberTwo); </script> </BODY> </HTML> What I need to do is to declare the two variables, swap their values and then show the results on the screen. ...but it's not working, any ideas? Thanks! x hi all i'm kind of new to the JS world and need your help with some thing i hope it not that big to ask. if you go to linkedin website with your user (www.linkedin.com) you will see a bar called LinkedIn Today. what i need is this kind of bar but with messages changing all the time(moving) is this some thing i need to write from scratch or there some example that i can use? any help will be good for me now because i need to do it ASAP regards,shay I have a slideshow that goes through pictures once you click on the Play button and doesn't stop until you press on the Stop button. How can I make it so that it automatically plays once the website loads without having to click on the Play button? Heres the code: Code: <div class="tabs png"><span class="tabs-inner"><a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a></span></div> <div class="slider-indent-button"> <a href="#" onClick='$("div.tabs").tabs().play();'>Play</a> <a href="#" onClick='$("div.tabs").tabs().stop();'>Stop</a> </div> All help is much appreciated!!! I'm quite new to JavaScript, but I wanted to add a feature to a sample website that I need to have done by tomorrow night. I have two HTML paragraphs which I will call "a" and "b". Below those paragraphs I have a text box and a submit button. This is how I declared them in the HTML doc: Code: <input type="text" name="message" value="Blank Message" id="newsmessage" /> Code: <input type="button" value="Post" id="submitbutton" onclick="updatepost()" /> Now when I click the submit button I want paragraph b to replace itself with paragraph a, and I want paragraph a to replace itself with the text in the text box. Here's the JavaScript that I have written. (I'm aware it's probably quite off.) Note: paragraph a is toppost, paragraph b is bottompost, the text box is named message, and I created p1 and p2 as temporary holders for the strings. Err... variables. Code: <script type="text/javascript"> function updatepost() { p2=document.getElementById("toppost"); document.getElementById("bottompost").innerHTML=p2; p1=document.message.elements[i]; document.getElementById("toppost").innerHTML=p1; } </script> As of right now the paragraph a holds the text "a" and paragraph b holds the text "b". When I click post paragraph a still reads "a" and paragraph b reads "[object HTMLParagraphElement]". Sorry for my minimal JavaScript knowledge; I have full intentions of fully learning the language quite soon. I just wanted to implement this feature in a site that I had to create and my deadline is tomorrow. Thanks guys! -Dave Hey, I've got to make the values of some textboxes change the co-ordinates of my sprite on a canvas and havent a clue on how to do it, Here is my form with the two textboxes and submit button: <form> x: <input type="text" name="x" /><br /> y: <input type="text" name:"y" /><br /> <input type="submit" value="Submit"/><br /> </form> And i need it so that they change the values of these: //this shows where my sprite will start on the canvas var block_x; var block_y; searched the internet for hours and cant really find anything i understand or works. any help is much appreciated I have a page that open two frames. Second frame, most of the page, is empty. First frame contains a form that retrieves user input, when you click the button, it send that input back to the original parent html, which detects the GET parameters, and builds a custom URL. I want to then load that custom URL in the 2nd empty frame. I figure I need to modify the src atttribute of the 2nd frame in the frameset, but I can't make it work. Code: <frameset id='parent' rows='10%,90%'> <frame id='frm1' src='./form.html' /> <frame id='frm2' src='' /> </frameset> <script>modFrmSrc();</script> where modFrmSrc() checks for the GET values, builds the URL, and then tries to load the URL in frm2. Is there a way to get this done? I am trying to dynamically add rows to a table when the user clicks a button. here my function Code: function addFocusArea() { if(addTlFocusAreaCount <= 5) { //Create new Title row var titleRow = document.createElement("tr"); var titleCol = document.createElement("th"); var titleText = document.createTextNode("Additional Focus Area " + addTlFocusAreaCount); titleCol.appendChild(titleText); titleRow.appendChild(titleCol); document.getElementById("focusTable").appendChild(titleRow); //Create new category row var categoryRow = document.createElement("tr"); var categoryCol = document.createElement("td"); var categorySelect = document.createElement("select"); var categories = document.getElementById("<%=DecisionToolKeys.PRIMARY_FOCUS%>"); //copy a dropdown menu that is already existing on the page for(var i=0; i<categories.length; i++) { var option = document.createElement("option"); option.value = categories[i].value; option.text = categories[i].text; categorySelect.options.add(option); } categoryCol.appendChild(categorySelect); categoryRow.appendChild(categoryCol); document.getElementById("focusTable").appendChild(categoryRow); addTlFocusAreaCount++; } else { alert("You cannot add more than five additional practice areas."); } } And here is my button Code: <input type="button" value="Add Focus Area" onclick="JavaScript:addFocusArea()"/> This is working in Firefox and Chrome, but not IE 8. Any clue as to why? Thanks, Nick Hi all, ok firstly i know all but nothing about javascript and you prob about to see the worst attempt eva at trying to understand it ok so here is my js code Code: <script language="javascript"> function selectElement(idElement) { var ratingval = ""; liElement = document.getElementById('sel'+idElement); lirating = document.ratingform.userrating.value; if(liElement == "sel1") { raingval = "1"; lirating = "1"; } if(liElement == "sel2") { raingval = "2"; lirating = "2"; } if(liElement == "sel3") { raingval = "3"; lirating = "3"; } if(liElement == "sel4") { raingval = "4"; lirating = "4"; } if(liElement == "sel5") { raingval = "5"; lirating = "5"; } } </script> and here is my html code Code: <form name="ratingform" action="" method="post"> <fieldset class="login"> <legend>Personal Details</legend> <div> <label for="fname">First Name</label> <input type="text" id="fname" name="fname" value="<?php if(isset($_POST['fname'])){ echo $_POST['fname'];}?>"> </div> <div> <label for="lname">Surname</label> <input type="text" id="lname" name="lname" value="<?php if(isset($_POST['fname'])){ echo $_POST['lname'];}?>"> </div> </fieldset> <fieldset class="contact"> <legend>Review</legend> <div> <label for="title">Review Title</label> <input type="text" id="title" name="title" value="<?php if(isset($_POST['title'])){ echo $_POST['title'];}?>"> </div> <div> <label for="review">Review</label> <textarea name="review" id="review" cols="33" rows="5"><?php if(isset($_POST['review'])){ echo $_POST['review'];}?></textarea> </div> </fieldset> <fieldset class="rating2"> <legend>Rating</legend> <div> <label for="rating">User Rating</label> <ul class="rating"> <li id="current" class="current" style="width: <?php echo $_GET['rating']?>em;"></li> <li id="sel1"><a onclick='onClick="javascript:selectElement(1)' class="rate1" title="I hated it">*</a></li> <li id="sel2"><a href="?rating=2" class="rate2" title="I disliked it">*</a></li> <li id="sel3"><a href="?rating=3" class="rate3" title="It was OK">*</a></li> <li id="sel4"><a href="?rating=4" class="rate4" title="I liked it">*</a></li> <li id="sel5"><a href="?rating=5" class="rate5" title="I loved it">*</a></li> </ul> </div> </fieldset> <div> <input type="hidden" name="userrating" value="" /> <input type="submit" name="Submit" value="Submit"><?php if($error == TRUE){echo $message;}if($submit == TRUE && $error == FALSE){echo $message;}?></div> </form> ok so what im trying to acheive is that when a user clicks on either of the rating links, a js function is run which gets the li value and then sets a value of a varible to match the li value and then i want to add that value to the hidden userrating form input and set the value of <li id"current" width value to the same value but as im sure youve noticed from my code it isnt working. any help it greatly needed and appreciated, thanks Luke I am new to java and tried writing the code for practice but it doesn't seem to work <html> <Head> <title>Discount</title> <script language ="Javascript"> <!-- function CalculateBalance(numItems,totPrice,discount) { var balance; balance = (1 - discount)*totPRice; alert ('Your balance is $'+balance +' Thank You.'); document.write("<br>YOu bought "+ numItems+" items for $"+totPrice); document.write("<br>Your balance is $"+ balance+" your discount was"+discount*100+"% Thank you"); } //--> </script> </head> <script language ="Javascript"> <!-- var discount; var numItems = parseInt(prompt('HOw many time did you buy [ >=12 is 20% and >= 6 is 10% discount]',"0")); alert ('You bought '+numItems +' items.'); document.write("You bought "+ numItems+" items."); var totPrice = parseFloat(prompt('The total price that you paid was',"0.0")); if(numItems >= 12) {discount = .2;} else if (numItems >=6) {discount+ .1} else {discount = 0;} CalculateBalance(numItems,totPrice,discount); //--> </script> </html> It only prints to the screen the number of items I bought Hi all, I sincerely apologise for the noob question. I have search and searched for an answer but to no avail, so I hope someone on here can help. I'm trying to get a fisheye verticle menu working. I've found somethin which fits the requirement he http://zendold.lojcomm.com.br/ifisheye/ and tried to make it work. It just doesn't. I've tried different versions of mootools etc but I think I'm missing something really stupidky simple. I'd really appreciate it if someone could have a look at my temp page (http://www.parkerbs.com/home1.htm) and point me in the right direction. Many thanks in advance. Paul I put the jquery script into my subdirectory. In the header which one is correct: Code: <script type="text/javascript" src="../jquery/jquery.js"></script> or Code: <script src="../jquery/jquery.js"></script> And there is this code: do I put this in the body and enclose it with the <script>tag? Code: $(function(){ // set interval for 5 minutes setInterval(function(){ $.ajax({url: "keep-alive.php"}); }, 300000); }); more or less when a user has a command pop up in this prompt they are asked to type another item from a list with an okay or cancel at the bottom how do i stop the script if a user hits cancel and move onto the calculation step and by pass the other imput prompts? sorry if this isn't the clearest, i am new at javascript. THanks in advance. I have a twitter widget at this side http://1905.gs/blog on the right sidebar. At the bottom of the widget there is the follow me link. I would like to embed a follow me "button" which I have created the script for: The button script: <a href="https://twitter.com/1905GS" class="twitter-follow-button" data-show-count="false" data-lang="tr">Takip et: @1905GS</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> And here is the current javascript link: http://www.1905.gs/blog/wp-content/p...tter-widget.js How I am trying to make it look like: http://a1202.hizliresim.com/u/d/2nryy.jpg thank you very much for your help, Hi all, I'm desperately trying to figure out how to "transform" Javascript commands into HTML code. Excuse my noobness but I really know nothing about Javascript. Basically, I have this Google API Search code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My Google AJAX Search API Application</title> <script src="http://www.google.com/jsapi?key=CUT"></script> <script language="Javascript" type="text/javascript"> //<![CDATA[ google.load("search", "1"); function OnLoad() { // Create a search control var searchControl = new google.search.SearchControl(); // Add in a full set of searchers var localSearch = new google.search.LocalSearch(); searchControl.addSearcher(localSearch); searchControl.addSearcher(new google.search.WebSearch()); searchControl.addSearcher(new google.search.VideoSearch()); searchControl.addSearcher(new google.search.BlogSearch()); // Set the Local Search center point localSearch.setCenterPoint("New York, NY"); // Tell the searcher to draw itself and tell it where to attach searchControl.draw(document.getElementById("searchcontrol")); // Execute an inital search searchControl.execute("Google"); } google.setOnLoadCallback(OnLoad); //]]> </script> </head> <body> <div id="searchcontrol">Loading...</div> </body> </html> Now, what I'm desperately trying to do since 4-5 hours is to have the search results between the <div id="searchcontrol"></div> encoded as HTML in the loaded page. Currently, when the page is loaded and I look at the source code, I have the word 'Loading...' in the <div> tags, despite in the normal view there are G results listed. I need those results encoded as HTML for SEO reasons. Researching on this matter I thought the problem could be the OnLoad command, that makes the script load after all the other HTML elements are loaded. But I tried to make it load before all the elements in the page, and the problem persists. How can I solve this? Thanks in advance for any help! Hi, Ever seen on the iphone where you have to slide the slider across the screen to unlock it? I have a duplicate of this using javascript but no matter what I try I cannot make it redirect. I want the page to be redirected after the slider has gone to the other side. Heres the HTML Code: <!DOCTYPE html> <head> <meta charset='UTF-8'> <title>Slide To Unlock</title> <link rel='stylesheet' href='css/style.css'> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'></script> <script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js'></script> <script src='js/slidetounlock.js'></script> </head> <body> <div id="page-wrap"> <div id="well"> <h2><strong id="slider"></strong> <span>slide to unlock</span></h2> </div> </div> </body </html> And the javascript Code: $(function() { $("#slider").draggable({ axis: 'x', containment: 'parent', drag: function(event, ui) { if (ui.position.left > 550) { $("#well").fadeOut(); } else { // Apparently Safari isn't allowing partial opacity on text with background clip? Not sure. // $("h2 span").css("opacity", 100 - (ui.position.left / 5)) } }, stop: function(event, ui) { if (ui.position.left < 551) { $(this).animate({ left: 0 }) } } }); // The following credit: http://www.evanblack.com/blog/touch-slide-to-unlock/ $('#slider')[0].addEventListener('touchmove', function(event) { event.preventDefault(); var el = event.target; var touch = event.touches[0]; curX = touch.pageX - this.offsetLeft - 73; if(curX <= 0) return; if(curX > 550){ $('#well').fadeOut(); } el.style.webkitTransform = 'translateX(' + curX + 'px)'; }, false); $('#slider')[0].addEventListener('touchend', function(event) { this.style.webkitTransition = '-webkit-transform 0.3s ease-in'; this.addEventListener( 'webkitTransitionEnd', function( event ) { this.style.webkitTransition = 'none'; }, false ); this.style.webkitTransform = 'translateX(0px)'; }, false); }); I need someone to make a small modification to this javascript code: <script type = "text/javascript"> function hyperlink() { var url = (location.href) url = url.replace(/\.(html)/i, "_2.html") window.location.href = url; } </script> Here is the situation: On this webpage: http://tehcake.com/video/30rock/2x14%20-%20Copyx.html where it says "Backup Links 1 2", if you click on the "1" in "Backup Links 1 2" it goes to this webpage, which is what it is supposed to do: http://tehcake.com/video/30rock/2x14%20-%20Copyx_2.html However, on this webpage, where it says "Backup Links 1 2", if you click on the "1" in "Backup Links 1 2" it leads to a non existing page by adding an extra "_2" to the end of the file name. Anyways, I need a way to modify this code (same one as above): <script type = "text/javascript"> function hyperlink() { var url = (location.href) url = url.replace(/\.(html)/i, "_2.html") window.location.href = url; } </script> This script subtracts ".html" and adds "_2.html" to the URL. Anyways, i need to change it so that if the filename has an _2.html in the file name, like in this URL: http://tehcake.com/video/30rock/2x14%20-%20Copyx_2.html the script would not add an extra _2 to the URL, instead it would just link to the same page. I dont know much about javascript so I need help to make this change. Hello everybody! This is my first post at CodingForums! I'm currently designing a wordpress theme, and I require a bit of javascript for a hover effect. I'm using Wordpress Jquery + Jquery Color Animations plugin. The structu I use a div (class="post") as a container for the wordpress post, and within the "post" div, I have a span (class="title") which I use to display the title of the post. What I want to do is: when the user hovers over (OnMouseOver) "post" div: ".title" spans's background color fades from black to red. when the user hovers out (OnMouserOut) "post" div: ".title" spans's background color fades back to black. The Code Code: $j(document).ready(function(){ $j(".posts").hover(function(){ $j (".posts .title").animate({ backgroundColor: "#FF0062" }, 300); },function(){ $j(".posts .title").animate({ backgroundColor: "#231F20" }, 300); }); }); The Problem The code works, except when the user hovers over any "post" div, all "title" span change color. So my question is, how do I target the code to address ONLY the "title" span in the "post" div that is in hover state? Any help would be greatly appreciated, Cheers, Drew. Ok javascript gurus, could someone help me out with a simple script? I have an array that I want to loop through and display the values of the array on the page as it loops (so I guess there should be a slight delay before the next one appears over it). I want to loop though until a button is clicked. Help? Is it possible to have an input that points to some other function? For example: Code: function someFunction() { alert('It worked.'); } function doAnotherFunction(doIt, otherFunction) { if (doIt == true) { otherFunction(); } } <input type="button" value="test" onClick="doAnotherFunction(true, someFunction());"> Or would I need a switch statement and have all the various functions hardcoded? |