Jump to content

Search the Community

Showing results for tags 'issues'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 4 results

  1. What's the issue? The example I am referring to is the Fisher Yates implementation on this page: https://www.w3schools.com/js/js_array_sort.asp This is the code in question: var points = [40, 100, 1, 5, 25, 10]; for (i = points.length -1; i > 0; i--) { j = Math.floor(Math.random() * i) k = points[i] points[i] = points[j] points[j] = k } If you run the example you will see the elements of the array shuffle around and everything will seem to be working as expected. The issue is subtle. With the above code block the element in the last position of the array can never remain in the last position of the array, and, with each iteration, the last element that is referenced can never remain in that position. Why can't the last element contain the same value after shuffle? It has to do with this statement: j = Math.floor(Math.random() * i) Because Math.random() generates a number between 0 and 1 which is inclusive of 0 but not inclusive of 1, the integer represented by i will never be assigned to j. With the above algorithm, i starts by referencing the last index of the array and therefore j can never be the last index. Why does this matter? This algorithm is supposed to produce an unbiased permutation of the elements meaning that every permutation is equally likely. With this shuffle, any element should have an equal chance of being shuffled into any position in the array including the position it already occupies. "Yeah, but, why would this matter in REAL LIFE?" In a practical example, I've needed to solicit feedback from users in a product. This was done by presenting a question with multiple possible answers. In order to prevent bias in the responses, the order the answers were presented was randomized for each person responding. From a code standpoint, each answer would have always started from the same position in the array. With this implementation, the last answer in the array would have never been the last answer presented to the user. This would have unknowingly introduced a different element of bias and skewed the results. Updated Implementations One possible update which still uses a for loop is to use the length of the array as the starting value of i and to decrement only after j has been randomly selected: var points = [40, 100, 1, 5, 25, 10], i, j, k; for (i = points.length; i > 0;) { j = Math.floor(Math.random() * i--) k = points[i] points[i] = points[j] points[j] = k } This looks a little wonky because even though the third statement in a for loop is optional, this is not a typical implementation. If we're going to decrement i inside of the code block, people typically use a while statement: var points = [40, 100, 1, 5, 25, 10]; var i = points.length, j, k; while (i > 0) { j = Math.floor(Math.random() * i--) k = points[i] points[i] = points[j] points[j] = k } I've also declared j and k before use. Generally it is considered good practice to declare variables before using them and using undeclared variables is not allowed in "strict mode".
  2. Ronja

    Mozilla design issues

    Hi. I am making a website for a friend who has a ridingcenter. I am having some issues with Mozilla. First issue is that i have used div, p and css to create a "link" line on the pictures in the image slider. This is working great in Chrome and Safari, but mozilla is for some reason splitting it in two lines. I have used <li> tags inside he <ul> which is the slider. Any idea on how i can get Mozilla to read it in the same way as chrome, or any better ways to do this? E.g. <li class="carousel-inner clearfix"> <img src="img/bilde3.jpg"> <div class="carousel-caption"> <p class="cycle"><a href="rideskole.html" class="button1">Vil du bli like god som Sigrid? <font size="2"> Trykk her</font></a></p> </div> </li> 2nd issue is that i have used instafeed to display instagram pictures in the end of the main page. Chrome and safari is displaying these according to the "zoom" design attribute, but mozilla for some reason dont display this, and is not zooming the pictures. Any idea why? Zoom is put in the CSS code: #instafeed { zoom: 1.6; margin: 8px 15px 15px 14px; padding:5px 5px 1px 5px; } I really hope for some good ideas, as i have spent a lot of time trying to solve this Best regards, Ronja
  3. Hello all, this is my first attempt at a real website to be posted in the future. It's at it's very basic stages. I've noticed a problem with the layout that needs fixing with Chrome, Firefox, and IE9. When the page is zoomed in or out, the layout shifts. How do I prevent this? HTML5 CODE: (Passes the W3C Validator) <!DOCTYPE html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta name="author" content="Joseph Maxwell Davies" /> <meta name="keywords" content="nomad, video, siblings, nomadic siblings, torah, teachings, articles" /> <title>Nomadic Siblings</title> <link type="text/css" rel="stylesheet" href="home.css" hreflang="en" media="screen" /> <script type="text/javascript" src="home.js"></script> </head><body> <div id="container"> <div id="webpagebanner"> <header> <hgroup> <h1>Nomadic Siblings</h1> </hgroup> </header> <div> </div> </div> <div id="leftsidebar"> <section id="logo"> <div> </div> </section> <nav id="leftsidebarnav"> <ul> <li>Home</li> <li>Videos</li> <li>Articles</li> <li>Contact Us</li> </ul> </nav> </div> <div id="maincontent"> <section> <div id="featuredcontent"> <figure> <!--<video height="320" width="480" controls="controls" poster=""> <source src="Wildlife.m4v" type="video/mp4" /> Your browser does not support HTML5 video please upgrade to one of the following: Chrome, Firefox, or IE9 </video>--> <img src="http://zipline.files.wordpress.com/2010/12/chanukah.jpg" alt="menorah" width="480" height="320" /> </figure> </div> <div class="featureselector"> </div> <div class="featureselector"> </div> <div class="featureselector"> </div> <div class="featureselector"> </div> <div class="featureselector"> </div> </section> </div> <div id="webpagefoot"> <footer> </footer> </div> </div> </body></html> CSS Code: body {/*background-image: url(https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRmopGs4E8JPZw2QSogetRzxjFhMbEPlyS8kY6hBd5mhgYQr-H4);*/background-color: #B57F35;}@font-face { font-family: Dumb1; src: url('2Dumb.ttf');}@font-face { font-family: Dumb2; src: url('3Dumb.ttf');}#container {/*background-color: white;*/width: 960px;margin-left: auto;margin-right: auto;}#webpagebanner {background-color: #EBE5AB;width: 790px;height: 150px;float: right;clear: right;border-top-right-radius: 25px;}#webpagebanner header hgroup h1 { text-align: center; width: 450px; margin-top: 35px; margin-left: 30px; /*background-color: white;*/ font-family: Dumb1; font-size: 42px;}#webpagebanner div { color: green; width: 700px; border: #B34242 solid 1px; margin-left: 45px;}#leftsidebar {background-color: #D9CE57;width: 169px;height: 760px;float: left;clear: left;border-right: blue solid 1px;}#logo { padding-top: 24px; padding-bottom: 24px; padding-left: 34px; padding-right: 34px; background-color: #D9CE57;} #logo div { height: 100px; width: 100px; background-color: red; border: black solid 1px; border-radius: 45px; }#leftsidebarnav { position: fixed;} #leftsidebarnav li { list-style-type: none; margin-top: 8px; margin-left: -1em; border-top: black solid 1px; border-bottom: black solid 1px; width: 120px; text-align: center; font-size: large; } #leftsidebarnav li:hover { background-color: white; opacity: 0.5; }#maincontent {background-color: #EBE5AB;width: 790px;height: 760px;float: left;}#maincontent section { border-bottom: black dashed 1px; padding-top: 15px; padding-bottom: 35px; padding-left: 164px; padding-right: 164px;} #maincontent section #featuredcontent { width: 480px; height: 320px; border: black solid 1px; border-radius: 50px; background-color: green; opacity: 0.5; overflow: hidden; } #maincontent section #featuredcontent figure { margin: 0px; overflow: hidden; border-radius: 50px; } #maincontent section .featureselector { width: 8px; height: 8px; border: black solid 2px; border-radius: 8px; float: right; margin-right: 10px; margin-top: 8px; background-color: red; }#webpagefoot {background-color: yellow;width: 960px;clear: both;} I use a local font but it's not really a big deal that you can't see it. How can I fix the layout so that it does not shift? P.S. Yes it's ugly right now, it's mostly laid out to show me the measurements and how the page is to be divided. Like I said it's bare bones. Or if better I have the files attached as well. But can't upload the ttf.... sorry about that. home.css index.html
  4. http://jsfiddle.net/xu79m/
×
×
  • Create New...