Results 1 to 3 of 3

Thread: Javascript that does not work on Mac

  1. #1
    Join Date
    Sep 2009

    Javascript that does not work on Mac

    Hi everyone, I am coding an internet page where I want to scroll images with "prev" and "next" buttons. I use Javascript there and the scrolling functions well on PC but not on Mac. Can anyone help me to find out what is wrong with the code? Thanks. Here is the code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <title>Gunilla Nadler, Läs poesibok</title>
    <meta name="GENERATOR" content="Microsoft FrontPage 3.0">
    <meta name="robots" content="all">
    <meta name="keywords" content="Gunilla Nadler, poesi">

    <link REL="stylesheet" href="docs/css/rules_ie.css" TYPE="text/css">

    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <base target="contents">

    <script language="JavaScript" type="text/JavaScript">
    var myImg= new Array(8)
    myImg[0]= "poesi_sid1";
    myImg[1]= "poesi_sid2";
    myImg[2]= "poesi_sid3";
    myImg[3]= "poesi_sid4";
    myImg[4]= "poesi_sid5";
    myImg[5]= "poesi_sid6";
    myImg[6]= "poesi_sid7";
    myImg[7]= "poesi_sid8";

    myImgSrc = "docs/images/";
    myImgEnd = ".jpg"
    var i = 0;
    function loadImg(){
    document.imgSrc.src = myImgSrc + myImg[i] + myImgEnd;

    function prev(){
    var l = i
    } else {
    var l = i-=1;
    document.imgSrc.src = myImgSrc + myImg[l] + myImgEnd;

    function next(){

    var l = i
    } else {
    var l = i+=1;
    document.imgSrc.src = myImgSrc + myImg[l] + myImgEnd;




    <body bgColor="#FFFFFF" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">

    <table width="100%" border="0" cellspacing=20 cellpadding=1">
    <td width=705 height="436">
    <div style="width:400px; height:300px; margin: auto;">
    <img name="Picture" id="imgSrc">


    <table border="0" cellspacing="0" cellpadding="0" style="border:1px solid #000000; width:710; margin: auto;">
    <td width="92" height="27"></td>
    <td class="textmeny3" width="705" height="27" align=center >
    <input type="button" value="föregående" onClick="prev();"> &nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp;
    <input type="button" value="nästa" onClick="next();">


  2. #2
    Join Date
    Jun 2003
    Please edit that to use [code] tags around your code like this [/code] which will make it much easier to read.

    And your problem is that your code doesn't work with any valid browser, use document.getElementById('ID') to select an element based on it's ID, not the IE only not even close to standardised document.ID

    And do you really need that many non-breaking spaces? Couldn't you just add some margins, or float an element, or(and I hate myself for suggesting it) use more than one table cell(Tables shouldn't be used for layouts BTW).
    If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
    The same applies to HTML and the forums [HTML][/HTML] tags.

  3. #3
    Join Date
    Sep 2009

    Thanks scragar

    Hi scragar, thanks for your help. Please tell me how exactly you would code in my case - I have tried with:

    document.getElementById("imgSrc").innerHTML = myImgSrc + myImg[i] + myImgEnd;

    but it does not work.

    Thanks in advance.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center