JavaScript - Javascript Pagination Help
I need help with pagination setup for my javascript image display.
The images I have now display when I select a certain category dynamically but I don't know how to implement javascript pagination into this code. I also don't know how to call it in my display page so that the images appear in a box and has separation in between them cause right now the images all display but connected to one another. I am new to javascript and the coding world so I really hope someone can help me out cause I've been trying to figure out how for the past 2 weeks now. Right now I have the code: Code: <div id="ImageContainer"></div> <br /> <script type="text/javascript"><!-- function ShowGallery() { // get parent for image container and remove image container var parentcontainer = document.getElementById("ImageContainer").parentNode; parentcontainer.removeChild(document.getElementById("ImageContainer")); // get current image gallery information from dropdown var dropdown = document.getElementById("catDropDown"); var selectedoption = dropdown.getElementsByTagName("option")[dropdown.selectedIndex]; var count = parseInt(selectedoption.getAttribute("Count")); // if there are not images in the category, return - "select a category" falls into this case as well if(count<=0) return; // populate images in image elements var container = document.createElement("div"); container.setAttribute("id","ImageContainer"); for(var i=0;i<count;i++) { var img=document.createElement("img"); img.setAttribute("src","images/th/thumb_"+dropdown.value+(i<9?"0":"")+(i+1)+".jpg"); img.setAttribute("alt","images/th/thumb_"+dropdown.value+(i<9?"0":"")+(i+1)+".jpg"); container.appendChild(img); } // Insert new image container back with new contents parentcontainer.appendChild(container); } Similar TutorialsI'm having a slight problem with php pagination and jquery/js. On the following page http://dev2.bluemuledesign.com/athletes.php you'll see an "athlete profile" area. Whenever an athlete photo is selected, javascript/php are used to switch out the athlete info. This works perfectly fine. The problem occurs if I use the left or right arrows to view more athletes (the left and right arrows are set with php pagination to switch to the next four records in the database). Whenever I do this, the athlete info defaults back to the first person from the initial load. Also, the javascript/jquery quits working and won't let me view the info for one of the newly displayed athletes. So I have two questions: 1) Can anyone tell me why it defaults back to the original athlete info? I'm assuming it has something to do with me not setting a cookie to remember the currently selected athlete. 2) Why does the javascript quit working when I view the next set of athletes? Also, the jquery slideshow that I am implementing is an alteration of this: http://designm.ag/tutorials/image-rotator-css-jquery/ Any help would be greatly appreciated. Hi. does anyone know how websites like www.fmylife.com or mylifeisaverage.com do their pagination? Do they just store all the posts in a database and then call them out? I'm asking this because I am wondering how I should paginate. Thanks
Hi, I have been playing with Slidersjs and have it sliding through my images just fine, however the previous/next and slide identifiers below the images don't seem to work and I can't see how to make them active. The temp link is he http://mono-zine.com/Mono.LogDM.html and the slide is the second one down. The identifiers should be clickable to take you to a specific slide, whilst they do change they dont click. Any help gratefully received. The script is from he http://slidesjs.com/ Cheers Hi, I have a table with a list of items which currently show 8 items per page. I want to have an input box at the top of the page so if I want a different amount of items to be shown i enter the number and the page alters the pagination to what ever number is entered. Hope this makes sense. Thanks for any help so.. im tryign to paginate a div with content being added by an input. but its not working at all... first, I got this input: Code: <form name="postbar_add_post" id="postbar_add_post" method="post"> <fieldset> <legend>What chu doign? ...</legend> <input type="text" name="addcontentbox" id="addcontentbox" maxlength="200" /> <input type="submit" name="addpost" value="Submit" class="submit" /> </fieldset> </form> then, what i will happen is that, the content being submited, will be posted to an unsorted list, named wall, i used jquery to help me out on this, heres the script: Code: <script type="text/javascript"> $(document).ready(function(){ $("form#postbar_add_post").submit(function() { var addcontentbox = $('#addcontentbox').attr('value'); if ( addcontentbox.replace(/\s/g,"") == "" ) return false; $.ajax({ type: "POST", url: "postear.php", data:"addcontentbox="+ addcontentbox, success: function(){ $("ul#wall").prepend("<li>"+addcontentbox+"</li>"); $("ul#wall li:first").fadeIn(); document.postbar_add_post.addcontentbox.value=''; document.postbar_add_post.addcontentbox.focus(); } }); return false; }); }); </script> the div where it is beign opsted at, looks like this: Code: <div id="cuerpo"><ul id="wall"></ul></div> adn then, below i got this div, wich is where the navgiation links will be at: (before u read, "current_page" and "show_per_page" are 2 hidden inputes to save the values.) Code: <div id="navwrapper"></div> so, to make the navigation, i found a script online and tried to adapt it to the div, i got this: Code: $(document).ready(function(){ //how much items per page to show var show_per_page = 5; //getting the amount of elements inside content div . var number_of_items = $('#wall').children().size(); //calculate the number of pages we are going to have var number_of_pages = Math.ceil(number_of_items/show_per_page); //set the value of our hidden input fields $('#current_page').val(0); $('#show_per_page').val(show_per_page); //navigation ' var navigation_html = '<a class="previous_link" href="javascript:previous();">Prev</a>'; var current_link = 0; while(number_of_pages > current_link){ navigation_html += '<a class="page_link" href="javascript:go_to_page(' + current_link +')" longdesc="' + current_link +'">'+ (current_link + 1) +'</a>'; current_link++; } navigation_html += '<a class="next_link" href="javascript:next();">Next</a>'; $('#navwrapper').html(navigation_html); //add active_page class to the first page link $('#navwrapper .page_link:first').addClass('active_page'); //hide all the elements inside content div $('#wall').children().css('display', 'none'); //and show the first n (show_per_page) elements $('#wall').children().slice(0, show_per_page).css('display', 'block'); }); function previous(){ new_page = parseInt($('#current_page').val()) - 1; //if there is an item before the current active link run the function if($('.active_page').prev('.page_link').length==true){ go_to_page(new_page); } } function next(){ new_page = parseInt($('#current_page').val()) + 1; //if there is an item after the current active link run the function if($('.active_page').next('.page_link').length==true){ go_to_page(new_page); } } function go_to_page(page_num){ //get the number of items shown per page var show_per_page = parseInt($('#show_per_page').val()); //get the element number where to start the slice from start_from = page_num * show_per_page; //get the element number where to end the slice end_on = start_from + show_per_page; //hide all children elements of content div, get specific items and show them $('#wall').children().css('display', 'none').slice(start_from, end_on).css('display', 'block'); /*get the page link that has longdesc attribute of the current page and add active_page class to it and remove that class from previously active page link*/ $('.page_link[longdesc=' + page_num +']').addClass('active_page').siblings('.active_page').removeClass('active_page'); //update the current page input field $('#current_page').val(page_num); } but all looks cool but... it is actually not working... everything its being posted great to the unsorted listt, but its not paging =S. .. it just all shows on the div, and scrolls. Could it be somethign on the css? ... or... what ...? =| Guidance? =( . my brains toasted. =\ On my website, I have a drop down selection for County which goes off and gets all pubs in that county using Ajax, which works fine: http://www.mypubspace.com What I would like to do is to pass through the PAGE (from the querystring too) here is my function on the drop down Code: <script> function countyFunction(){ var countyRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari countyRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ countyRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ countyRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server countyRequest.onreadystatechange = function(){ if(countyRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = countyRequest.responseText; } } var name = document.getElementById('name').value; var rsCounty = document.getElementById('rsCounty').value; var page = document.getElementById('page').value; var queryString = "?name=" + name + "&rsCounty=" + rsCounty + "&page=" + page; //Add the following line countyRequest.open("GET", "http://www.mypubspace.com/countypubs.php" + queryString, true); countyRequest.send(null); } </script> <select name="menu2" onChange="countyFunction();" class="textbox" id="rsCounty"> <option value="">Search by County...</option> <? $county_pubs = mysql_query("SELECT DISTINCT RSCOUNTY, COUNT(PUBID) As PubCount1 FROM pubs GROUP BY RSCOUNTY ORDER BY RSCOUNTY ASC") ?> <?php while($row1 = mysql_fetch_array($county_pubs)) { echo '<option value="'.$row1['RSCOUNTY'].'">'.$row1['RSCOUNTY'].' ('.$row1['PubCount1'].')</option>'; } ?> </select> <input type='hidden' id='name' /> <input type='hidden' id='rsCounty' /> <input type='hidden' id='rsTown' /> <input type='hidden' id='page' /> and on the following page is my data and pagination: Code: <?php if ($msg <>"") { echo "<div class=\"ui-widget\"> <div style=\"padding: 0pt 0.7em;\" class=\"ui-state-error ui-corner-all\"> <p style=\"padding-top:18px;\"><span style=\"float: left; margin-right: 0.3em;\" class=\"ui-icon ui-icon-alert\"></span> <strong>Alert:</strong> $msg</p> </div> </div>"; } $tableName="pubs"; $targetpage = "county_pubs.php"; $limit = 20; $query = "SELECT COUNT(*) as num FROM $tableName WHERE RSCOUNTY = '".$County."'"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages['num']; $stages = 3; $page = mysql_escape_string($_REQUEST['page']); if( isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) ) { $page = (int) $_GET['page']; $start = ($page - 1) * $limit; }else{ $start = 0; } // Get page data $query1 = "SELECT * FROM $tableName WHERE RSCOUNTY = '".$County."' ORDER BY rsPubName asc LIMIT $start, $limit"; $result = mysql_query($query1); // Initial page num setup if ($page == 0){$page = 1;} $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total_pages/$limit); $LastPagem1 = $lastpage - 1; $paginate = ''; if($lastpage > 1) { $paginate .= "<span class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='$targetpage?page=$prev&rsCounty=$County'>previous</a>"; }else{ $paginate.= "<span class='disabled'>previous</span>"; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter&rsCounty=$County'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter&rsCounty=$County'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1&rsCounty=$County'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage&rsCounty=$County'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='$targetpage?page=1&rsCounty=$County'>1</a>"; $paginate.= "<a href='$targetpage?page=2&rsCounty=$County'>2</a>"; $paginate.= "..."; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter&rsCounty=$County'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1&rsCounty=$County'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage&rsCounty=$County'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a id='page' href='$targetpage?page=1&rsCounty=$County'>1</a>"; $paginate.= "<a id='page' href='$targetpage?page=2&rsCounty=$County'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a id='page' href='$targetpage?page=$counter&rsCounty=$County'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a id='page' href='$targetpage?page=$next&rsCounty=$County'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</span>"; } echo 'Pubs found: '.$total_pages; // pagination echo $paginate; ?> <div id="accordion"> <?php while($row = mysql_fetch_array($result)) { echo '<div><h3><a href="#">'.$row['rsPubName'].', '.$row['rsTown'].'</a></h3><div>'.$row['rsAddress'].'<br />'.$row['rsTown'].', '.$row['rsCounty'].'<br />'.$row['rsPostCode'].'<br /><br />Region: '.$row['Region'].'<br /><br />Telephone: '.$row['rsTel'].'<br /><br />'; echo '<button onclick="gohere(\'viewpub.php?PUBID='.$row['PUBID'].'\')" type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">View Pub</span></button>'; echo '</div></div>'; } echo '<span style="float:right;">'.$paginate.'</span>'; ?> I'm trying to create a type of virtual pagination that's simple, semantic, and SEO friendly. The concept is like this website: www.doner.com In the bottom right hand corner, if you select a city, different contact information appears. My theory is to assign a class name to the hyperlink, then have a DIV with a matching ID. For example... Code: <a href="#" class="michigan">Michigan</a> <a href="#" class="ohio">Ohio</a> <a href="#" class="illinois">Illinois</a> <div id="michigan"> Michigan container </div> <div id="ohio"> Ohio container </div> <div id="illinois"> Illinois container </div> The JavaScript I have written so far is... Code: var anchor = document.getElementsByTagName('a').className; // grab all hyperlinks and their classes var div = document.getElementsByTagName('div').getElementByID; // grab all divs and their IDs if (anchor = div) { // check to see if a hyperlink's class has a matching div ID div.style.display = "none"; if (anchor.onclick) { // if the hyperlink is clicked... div.style.display = "visible"; // make matching div ID visible } } Nothing works yet, and I don't know where to continue. The DIVs aren't even hidden upon loading. Can anyone help me? Hello all, I need some help with pagination on the web page that am working right now. There are images(more than 50) on this page which I want to show as gallery. Each image has few details about the photograph beside it. Right now all these images and details are shown in a single page one after the other with div's and am setting these div tags using JS array. I have found several javascripts in google which can do pagination/ gallery for simple images. But my problem is these are not simple images but zoomable images. So when am using these scripts my first zoomable image is shown properly. But from next image, the details of the photo are changing but my zoomable image is not loading. I am fairly new to JS. It would be great if someone can point in right direction. I am exploring Spry Widgets to do this but wanted to know if there is any other simple or better way to do it. Thanks in Advance, Shravanthi Hello! I am trying to find a script that allows you to open multiple browser tabs and then close each of those tabs, either one by one or all at once. Does anyone know how to do this please? Thanks so much for your help. I want to have another go at Javascript. I have several books on the subject but I find that my eyesight is a major problem. Therefore I want to try an on-line solution, preferably free. I have Googled, but there are so many that I am almost dizzy with the choices. Perhaps someone could recommend one. Not too fussy visually. My knowledge is VERY basic. Frank Does anyone know how to make URL links that use Javascript still work when users have Javascript disabled on their browser? The only reason I'm using JS on a URL is because my link opens a PDF file, and I'm forcing it not to cache so users have the latest version. I tried the <script><noscript> tags, but I'm not sure if I'm using it correctly, as my URL completely disappears. Below is my HTML/Javascript code: <p class="download"> <script type="text/javascript">document.write("<span style=\"text-decoration: underline;\"><a href=\"javascript:void(0);\" onclick=\"window.open( 'http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf?nocache='+ Math.floor( Math.random()*11 ) );\" >The Child Magazines Media Kit</a></span> (PDF 1 MB) ");</script> <noscript><span style="text-decoration: underline;"><a href="http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf" >The Child Magazines Media Kit</a></span> (PDF 1 MB)</noscript> </p> Thanks for any help, Michael Hi Guys, I am new at JavaScript and start to do some tutorials.What I am trying to do here is prompting user to input a name and if the name was valid the page(document) will display with all objects like the button.But if user enter a wrong name then the button will be disabled! I create the following code but it did not work <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Web Project</title> <script language="JavaScript" type=""> function changeColor(){ document.bgColor = "Gray"; } </script> </head> <body> <script language="JavaScript" type="text/javascript"> var person = ""; person = prompt('What is Your Name:'); if (person == "Foo") { document.write("<h1 />Welcome " + person); document.bgColor = "Yellow"; } else { document.write("<h1 />Access Denied!!!!"); document.bgColor = "Red"; document.getElementById("gree").disabled = true; } </script> <div> <p/><input id="gree" type="button" value="Gray " onClick="changeColor();"> </div> </body> </html> as you can see I used the: document.getElementById("gree").disabled = true; but it did not work , could you please give an idea how I can solve this problem? Thanks Hi, I have the following code snippet: test.html ====== <script language="javascript" type="text/javascript"> var testVariable = "test"; </script> <script language="javascript" type="text/javascript" src="test.js"> </script> test.js ===== var testVariable = window.top.testVariable; In firefox, I'm able to access testvariable defined within test.html in test.js. But in chrome, test.js couldnot get the window.top.testVariable field defined in test.html. Can any one please let me know how i can make it work in chrome?. Am i missing something here?. I got an index.php Code: <html> <form action="bacakomik.php" method='post'> <select name="kodekomik"> <option value='../komik1/|23'>Judul Komik1</option> <option value="../komik2/|20">Judul Komik2</option> <option value="../komik3/|10">Juduk Komik3</option> <option value="../komik4/|20">Judul Komik4</option> </select> <input type="submit" /> </form> <?php echo ('<select>'); echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); echo ('</select>'); ?> </html> As you can see, each of the option brings specific value "../komik1/|23" komik1 is a directory | is a delimiter 23 is the pages in one chapter and can be considered also as how many images are there on a specific directory This is my bacakomik.php Code: <?php $dirkomik = $_POST['kodekomik']; $exploded = explode("|", $dirkomik); echo ($exploded[0]); //picture directory echo ("<br>"); echo ($exploded[1]); //total page in the comic $pagecount = (int)$exploded[1]; //Take last posted value, process it right away echo ('<FORM name="guideform"> '); echo ('<select name="guidelinks">'); $i=1; do { echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); $i= $i+1; }while($i <= $pagecount); //Printing option and select echo ("</select>"); ?> <input type="button" name="go" value="Go!" onClick="document.getElementById('im').src=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value+'.png';"> </FORM> <img src="img0.jpg" id="im"> With the current code on bacakomik.php, I only can change the img src of id "im" in the same directory only. What I want is that the Javascript could "add" the "$exploded[0]" variable so that the picture can be loaded from different directory. Anyone can do this? I believe that the fix should be somewhere on input tag inside OnClick, or do you know where? Anyway, I found this on the net http://p2p.wrox.com/php-faqs/11606-q...avascript.html Please help me to those who can... Hi Guys I am trying to modify the functionality of my page. I want to be able to activate this piece of code using another javascript function. This is the code I want to activate: Code: <script type="text/javascript"><!-- $('#button-cart').bind('click', function() { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea, .date_data input[type=\'text\']'), dataType: 'json', success: function(json) { $('.success, .warning, .attention, information, .error').remove(); if (json['error']) { if (json['error']['warning']) { $('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.warning').fadeIn('slow'); } for (i in json['error']) { $('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>'); } } if (json['success']) { $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.success').fadeIn('slow'); $('#cart_total').html(json['total']); $('html, body').animate({ scrollTop: 0 }, 'slow'); } } }); }); //--></script> And this is how I want the format of the function to be: function testsession() { if there is a session called 'hiredate' { activate the script above } else { var el = document.getElementById("product_data"); } } I just dont know how to write this in javascript Could you help me if possible please 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 want to insert this js snippet Code: function addText(smiley) { document.getElementById('message').value += " " + smiley + " "; document.getElementById('message').focus(); return false; } to a loaded iframe with name&id chtifrm. I can access it & change embed something in its html via using something like: Code: $(parent.chtifrm.document.body).append('<div id=\"smly\" style=\"cursor:pointer;float:left;top:200px;display:none;position:absolute;\"><\/div>'); .... Code: parent.chtifrm.document.getElementById('chatbox_option_disco').style.display == 'none' but how do I insert js in the head of loaded iframe? All -- I have a JavaScript config file called gameSetting.js which contains a bunch of variables which configures a particular game. I also have a shared JavaScript library which uses the variables in gameSetting.js, which I include like so: <script type="text/javascript" src="gameSetting.js" ></script> <script type="text/javascript" src="gameLibrary.js" ></script> In gameSetting.js I have: $(document).ready(function() { // call some functions / classes in gameLibrary.js } in Firefox, Safari, and Chrome, this works fine. However, in IE, when it's parsing gameSetting.js, it complains that the functions that live in gameLibrary.js aren't defined. When it gets to parsing gameLibrary.js, the variables in gameSetting.js are reported as not being defined. I've tried dynamically bootstrapping the gameLibrary file using this function in document.ready for dynamic load... $.getScript("gameLibrary.js"); However, the same problem still happens in IE, where when it parses the files individually it's not taking into context the file/variables that came before, so it's not an out of load order problem. My options a 1) collapsing all the functions in gameLibrary.js and variables in gameSetting.js into one file. However, this is not practical because this is dealing with literally hundreds of games, and having a gameLibrary.js in ONE location for ONE update is what makes most logical sense. 2) figure out a way to get this to work where variables in file1 are accessible to file2 in IE (as it seems they are in other browsers). jQuery seems to be able to have multiple plugins that all refer to the based jQuery-1.3.2.js, so I know there is a way to get this to work. Help appreciated. Nero I wrote a log function that took note of various function calls. Thinking that functions are first class objects, and objects have properties, I made the name of each logged function a property of that function, e.g., brightenInnerPara.name = "brightenInnerPara"; Every browser I tried (Firefox, MSIE, Opera, Chrome, Safari) accepted the assignment, no problem. In Firefox and MSIE, the result was what I wanted: brightenInnerPara.name == "brightenInnerPara" But in the others, the result was: brightenInnerPara.name == null Question 1. Which Javascript is correct here? I favor Firefox and MSIE, not merely because they were willing to give me what I wanted, but also because it makes no sense to accept an assignment statement without throwing an error and then give it a null semantics, like Chrome, Opera, and Safari did. I found a workaround, using assignments like this: brightenInnerPara.prototype.name = "brightenInnerPara"; To my surprise, that worked in every browser. But I don't know why. It seems that such assignments are enough to cause each function to have its own distinct prototype. Question 2. Just how inefficient is my workaround, and why does it work? I have a javascript file called ad.js inside looks like this Code: var ADPLACER_PATH = "http://www.mywebsite.com/"; var PREROLL_ENABLED = 1; var MIDROLL_ENABLED = 0; var PREROLL_ZONE_ID = 0; var MIDROLL_ZONE_ID = 0; var PREROLL_TIMEOUT_IN = 0; var PREROLL_TIMEOUT_OUT = 35000; var PREROLLCLOSEBUTTON_TIMEIN = 0; var MIDROLL_TIMEOUT_IN = 0; var MIDROLL_TIMEOUT_OUT = 3000000; var PREROLL_ONSHOW = function(C){ setTimeout(function(){document.getElementById('adplacer_prerollClose'+C).onclick()}, PREROLL_TIMEOUT_OUT); } var PREROLL_ONHIDE = function(){} document.write ("<scr"+"ipt type='text/javascript' src='"+ADPLACER_PATH+"adss.js'><\/scr"+"ipt>"); It places an ad over a video on my site. I know I can add the .js to my site by adding this <script type="text/javascript" src="ad.js"></script> to my head But what do I need to add to my page to make it appear? Do I have to put the video between a DIV? Can someone let me know what I need to do to make it appear? thanks |