LinkedIn Javascript SDK working in Chrome, not Safari - javascript

I have the following JS code in my <head> tag:
<script>
function hello() {
alert('blah');
}
</script>
<script type="text/javascript" src="https://platform.linkedin.com/in.js">
onLoad: hello
api_key: xxxxx
</script>
In Chrome (61.0.3163.100), this alert's successfully, but in Safari (11.0 (13604.1.38.1.6)), nothing happens with any console message or anything to go on. Needless to say I am unable to use any SDK functions. I've checked the network inspector and the SDK is indeed being loaded. I have a very high percentage of Safari users so I can't ignore them. Any suggestions?

Related

Loading a txt file with jQuery [duplicate]

I am trying to get into jquery/ajax and I can't even believe I can't get past this first test. I'm following an example I found at The Jquery API site and I followed it just about to a T.
I created a local folder on the desktop, and added 2 files.
index.html
and
list1.html.
Index.html:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<div id="stage">
</div>
<script>
$( "#stage" ).load( "list1.html" );
</script>
</body>
</html>
list1.html
<div id="list">
<li>Test</li>
<li>Foo</li>
<li>Bar</li>
</div>
I was trying for like 15 minutes to run index.html in chrome and nothing displayed (like the jquery wasn't loading correctly). Out of pure curiosity I opened it with firefox and it displayed as expected.. something like this
Test
Foo
Bar
So is this a browser issue? Why does Chrome and IE not show this loaded list, but firefox does? I can't figure out if it's my code or the environment which is infuriating when trying to learn.
Try launching chrome / chromium with --allow-file-access-from-files flag set
See How do I make the Google Chrome flag "--allow-file-access-from-files" permanent?
Try
<script>
$(function(){
$("#stage").load("list1.html");
});
</script>
If still not works, check the Network section in the Developer Tools of your browser and see if there are any HTTP or Security errors.

google visualization google.load weirdness in Microsoft Edge

I am loading Google Visualization (for the core chart module) and am having issues with Microsoft Edge 20.1040.16384.0.
Here is a pared down version of the page which does nothing other than load the module:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':['corechart']});
</script>
</head>
<body>
</body>
</html>
I am getting "Unexpected end tag." on the console reported on line 7 (the close tag on the block that is running google.load
Does anyone have any clue what is going on here?
P.S. The non-pared down version of my page (not shown here) is working fine in Chrome, but there are some issues in Firefox (though no error on the console)... so I am wondering if the Firefox issue might be connected to this. But I figure I can solve this issue and then try to figure out what is happening with Firefox.

Some scripts not loading in Chrome

I have the following script tags (JSFiddle)
<script src="//tags.mediaforge.com/js/1180"></script>
<script src="//s.adroll.com/j/roundtrip.js"></script>
<script src="//code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="//connect.facebook.net/en_US/all.js"></script>
<script src="//i.kissmetrics.com/i.js"></script>
The first two don't load. I get the following errors in the Dev Tools console:
And the following appears under "Other" in the Network tab:
And here are the headers for the first one (notice there is no response):
When I open the same page in incognito, it works and the headers are different
I've reproduced this with Chrome 30 and 31.0.1650.57 (both 64-bit) on Ubuntu 12.04. Chrome 31.0.1650.57 m on by Windows 7 VM works fine. I've had some people able to reproduce this and some not.
Any ideas what is going on here?

External JavaScript Files will not execute in IE9

The following is a snippit from my a little web page I'm putting together.
<script type="text/javascript" src="head.js">
</script>
<title>CPST 3410-85 Class Template</title>
</head>
<body onload="outputToDiv();">
The head.js file referenced in the script tag is below:
function outputToDiv() {
alert("JavaScript is working!");
}
In Chrome and in Firefox the alert is displayed indicating the JavaScript is working. In IE9 it is not. Furtermore I can't get ANY external script to run in IE9, regardless of the content. I have used custom security settings and lowered in a granular way every security setting to its lowest level, and gone into advanced settings and enabled literally everything I could find.
It should be noted that I am opening this from a local folder. All files are in the same folder, and again I stress that this works in firefox and chrome.
In IE9 I have enabled debugging and I get the error below:
Webpage error details
Message: Invalid character
Line: 1
Char: 1
Code: 0
URI: file:///E:/My%20Documents/My%20Web%20Sites/CPST341085/head.js
Of course it then tells me that "outputToDiv()" is undefined.
I am at a total loss here.
I got this behavior when I had:
<script type="text/javascript" src="jquery-1.7.1.js" />
However, this fixed it:
<script type="text/javascript" src="jquery-1.7.1.js"></script>
Go figure...
David

jQuery script not working when page viewed on localhost

I'm just starting to playing around on a Mac for the first time and I have created a very simple HTML page that uses jQuery to do a simple text swap when an h1 tag is clicked.
When I don't view the page through the webserver and just open it directly in Safari (file:///Applications/xampp/xamppfiles/htdocs/test/mypage.html) it works as expected. However, when I try to view through Apache (http://localhost/test/mypage.html) it doesn't work.
Here's the code:
<html>
<head>
<title>My Awesome Page</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" charset="utf-8">
function sayHello()
{ $('#foo').text('Hi there!');
}
</script>
</head>
<body>
<h1 id="foo" onclick="sayHello()">Click me!</h1>
</body>
</html>
Am I missing something on the Mac? Wouldn't be an Apache setting since its client-side code.. right?
I should probably also mention that I loaded XAMPP to run Apache and MySQL. I have tested Apache to ensure its working using a simple PHP file.
Steve
Use Firebug and access the page. One things that might be a culprit is that the web server cannot open jquery.js file because of file permission. Firebug will show if the jquery loaded in page, even you can add the jQuery code on-the-fly in the Console tab.
If you access it using Safari, use Web Inspector and see the if any error showed in Console tab.
One last thing, make a habit to avoid onclick, do this instead:
<script type="text/javascript" charset="utf-8">
function sayHello()
{
$('#foo').text('Hi there!');
}
//wait DOM loaded
jQuery(function($){
$('#foo').click(function(){
sayHello();
});
});
</script>
Also, it's better to put the js code near the page end, before </body>, so it would not block concurrent page element's loading.

Categories

Resources