Does the feature function properly in IE9 and Firefox 4 but not in IE7 or IE8?

I created this script a while ago and recently updated it to utilize css sprites in order to reduce the number of images. While everything functions perfectly in ie9 and ff4, I have discovered that it fails to display properly in ie7/ie8... This issue seems to be related to either css or js, but after careful inspection, I am unable to identify any reasons why the older versions of Internet Explorer are not rendering the code...

I have included the complete contents below on a 'test' page that contains all the elements... If anyone can assist me in pinpointing why this isn't working in ie7 or ie8, I would greatly appreciate it!

<!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" xml:lang="en">
<head>
<style type="text/css">    
#social16 {height:16px;font-size:13px; color:#0066ff; font-weight:bold;}
#sb16 {margin: 0px; padding:0px; height:16px; display: inline;line-height:16px;}
#sb16 li {list-style-type:none;float:left;padding:0 5px 0 0;}
#sb16 li a {background:url(social.png);background-repeat:no-repeat;display: block;height: 16px;width:16px;}
#sb16 li a.item0 {background-position:0px 0px;}
#sb16 li a.item1 {background-position:-16px 0px;}
#sb16 li a.item2 {background-position:-32px 0px;}
#sb16 li a.item3 {background-position:-48px 0px;}
#sb16 li a.item4 {background-position:-64px 0px;}
#sb16 li a.item5 {background-position:-80px 0px;}
#sb16 li a.item6 {background-position:-96px 0px;}
</style>
</head>
<body>
<div id="social16"></div>
<script type="text/javascript" defer>
(function(){

var sites = [
        ['Send to Facebook', 'http://www.facebook.com/sharer.php?u={url}&amp;t={title}'],
        ['Tweet This', 'http://twitter.com/share?text={title}&amp;url={url}'],
        ['Send to StumbleUpon', 'http://www.stumbleupon.com/submit?url={url}&amp;title={title}'],
        ['Digg This', 'http://digg.com/submit?phase=2&amp;url={url}&amp;title={title}'],
        ['Send to GoogleBuzz', 'http://www.google.com/buzz/post?message={title}&amp;url={url}'],        
        ['Send to Reddit', 'http://reddit.com/submit?url={url}&amp;title={title}'],
        ['Email to Friends', 'mailto:?subject={title}&amp;body={url}'],
    ];

var url = encodeURIComponent(location.href),
    url = url.replace( "#", "" ),
    title = encodeURIComponent(document.title),
    html = '<ul id="sb16"><li>Share this ... </li>';

for (var i = 0; i < sites.length; i++) {
    var site = sites[i],
    link = site[1].replace('{url}', url).replace('{title}', title);

    html += '<li><a class="item' + i + '" href="#" title="' + site[0] + '" onclick="window.open(\'' + link + '\')"></a></li>';
}

html += '</ul>';

document.getElementById("social16").innerHTML=(html);

})();
</script>
</body>
</html>

Answer №1

Be cautious of placing a comma after the last element in the sites array:

var sites = [
    //...
    ['Email to Friends', 'mailto:?subject={title}&amp;body={url}'],
    // -----------------------------------------------------------^
];

Internet Explorer 6 and 7 may encounter issues with this syntax. It can result in unexpected null values at the end of the array.

Answer №2

let websites = [
        ...
        ['Email to Friends', 'mailto:?subject={title}&amp;body={url}']
    ];

The final item in your array has an extra comma at the end. Please remove it.

For more information, visit this link.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with series of node commands getting stuck on npx command

I have a custom node script that I use to automate the setup of my application. This script creates directories, generates files, and executes a series of node commands. Everything functions correctly for the most part. The specific commands being executed ...

Click to execute instantly without encountering any errors

I'm working with a modal in React JS and I want to trigger a function when the modal opens. I currently have a button function that is functioning correctly using the following code: <button onClick={functionExample("stringParam", true)} ...

Ways to update a component from another in React

My React code includes an Employees page that renders both a Table component and a Filter component. The Filter component manipulates some data stored in the Employees page, updates the Filter's state through useEffect, and passes the data as a prop t ...

Tips for generating a safe token for your application

A new project I'm working on involves creating a simple app that allows users to log in. Through an ajax function, I pass the login values to a PHP file on a different domain. If the user's login credentials are correct, the page displays "succes ...

Leveraging Data from main.js in VueJS Templates: A Step-by-Step Guide

I defined my Vue scope in the main.js file like this: new Vue({ el: '#app', router, template: '<App/>', components: { App }, data: { name: 'Levi' } }) Now, I want to access it in my template file named ...

What causes the difference in behavior between using setInterval() with a named function as an argument versus using an anonymous function?

I can't seem to figure out why using the function name in setInterval is causing issues, while passing an anonymous function works perfectly fine. In the example that's not working (it's logging NaN to the console and before the first call, ...

What is the best way to create a transparent section within a div to reveal the content below?

My goal is to create a user interface that resembles the design shown in this image https://i.stack.imgur.com/GfiZ8.png One issue I'm facing is how to make the center of the top div circular and transparent, just like in the reference image. I consi ...

Is it true that all events in JavaScript go through capturing and bubbling phases?

My current project involves binding one eventListener to an <audio> element for the play event and another eventListener to its parent element for the same event. I've observed that the callback for the child element always gets executed, while ...

The problem with the connection between nodes is that the object function createServer does not have a static

I'm attempting to start my node server following an example from a book on AngularJS (server.js). var connect = require('connect'); connect.createServer( connect.static("../angularjs") ).listen(5000); At first, I encountered the error "obj ...

Position card boxes in the center using bootstrap

Hey there! I'm facing an issue with my two cards (check out the image below) https://i.sstatic.net/XDWop.png It seems like the card boxes are not perfectly centered. I've made some adjustments in the code snippet provided. Could you please lend ...

The scraping tool from Snipcart encountered issues while trying to capture product data in a Next.js

I am encountering an issue with Snipcart while using it in a Next.js app integrated with Strapi. The error message I receive when processing a payment is as follows: A 'cart-confirmation' error occurred in Snipcart. Reason: 'product-craw ...

Issues with jwplayer functionality

After downloading the necessary files and carefully following all instructions, I am still experiencing issues with the player not functioning as expected. <code> <html> <head> <script type="text/javascript" src="/jwpl ...

Emptying the AnyChart (Javascript) container prior to generating new charts

I have been utilizing the anychart JavaScript library to generate a pie-chart from my data, which is dynamically pulled whenever a user modifies a dropdown selection. Below is the code snippet I am employing for this purpose: var stage = anychart.graph ...

What is the reason for needing to multiply all the numbers by ten in order to solve this floating point addition problem?

When dealing with floating point arithmetic in Javascript, it's common to see results like 0.2 + 0.1 = 0.30000000000000004, which can be confusing. However, a simple workaround is to multiply the numbers by 10, perform the operation, and then divide b ...

What is the best way to conceal a canvas or another item?

Within my main canvas, there are three smaller canvases and a text element. <canvas id="Background" width="350" height="300" style="border:6px solid black; position: absolute; left: 10px; top: 10px;"> </canvas> <canvas id="Canvas1" width ...

Ways to position <label> and text next to each other in HTML

I have a query about aligning a label and text side by side horizontally. How can I adjust their alignment to center the text within the label rather than at the bottom of it? Below is my current HTML code: <div> <label class="switchnmn"> ...

Creating an interactive accordion table using vue.js and the v-for directive in the main element

Looking for some help on implementing this feature using VUE: https://jsfiddle.net/jacekpr/roschwvL/5/ Currently, my progress is here: https://jsfiddle.net/jacekpr/8bhpqc5s/13/ However, I'm facing an issue with having multiple root elements in the ...

Create a customized MUI select component with a label, all without the need for assigning an

One issue I am facing is with the Material UI React select component being used multiple times on a page. In the examples, all labeled selects use InputLabel with htmlFor that must match the id of the select. The challenge is that I cannot assign an id t ...

Displaying a web page consistently across different browsers

My code is available at . It displays correctly in all browsers except Mozilla Firefox. In Firefox, the text box appears too wide and too high. Can anyone suggest an easy fix for this issue? I'm not sure what's causing it. ...

What could be causing my HTML table to resize images from left to right?

My latest attempt at creating a simple HTML table involved filling it with placeholder images and spacing them out using a background color. However, the end result was not what I expected: https://i.sstatic.net/kyRil.png Upon closer examination, you&apo ...