I tried hard to find this error, deleted all unnecessary nodes. but still,
I can't find it.
Uncaught SyntaxError: Unexpected end of input test.html:28
html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>파일 다운로드</title>
</head>
<body>
<div class="wrap">
<table width="500" cellpadding="0" cellspacing="0" border="1" class="blueone">
<tr>
<th>파일명</th>
<th>진행상황</th>
<th>다운로드</th>
<th>시정지</th>
</tr>
<tr>
<td id="100Mb.dat">File10MB</td>
<td><progress id="progress" value="0"></progress><span id="display"></span> </td>
<td class="test"><a class="checkBtn checkBtn1" onclick="downloadFile(event, "100Mb.dat")">다운로드</a></td> //Uncaught SyntaxError: Unexpected end of input
<td><a class="pauseBtn pauseBtn1" onclick="stop(1);" value="ACTION">일시정지</a><a class="resumeBtn resumeBtn1" onclick="resume(1);" value="ACTION">다시시작</a></td>
</tr>
</table>
</div>
</body>
</html>
The problem is with
onclick="downloadFile(event, "100Mb.dat")"
You can't have double quotes within double quotes here.
Either escape the inner quotes or use single quotes for one pair.
As said in the error, line 28:
onclick="downloadFile(event, "100Mb.dat")"
You are using double quotes for "100Mb.dat", which is breaking the onclick ones. And browser parses (understands) it this way..
onclick="downloadFile(event, " 100Mb.dat ")"
Inside double-quote use semi-quote mark like this:
onclick="downloadFile(event, '100Mb.dat')"
All code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>파일 다운로드</title>
</head>
<script language="JavaScript" type="text/javascript" src="js/jquery-3.2.1.js"></script>
<script src="js/myscript.js"></script>
<!-- <script src="js/downloadJs.js"></script> -->
<script src="js/distribute.js"></script>
<body>
<div class="wrap">
<table width="500" cellpadding="0" cellspacing="0" border="1" class="blueone">
<tr>
<th>파일명</th>
<th>진행상황</th>
<th>다운로드</th>
<th>시정지</th>
</tr>
<tr>
<td id="100Mb.dat">File10MB</td>
<td><progress id="progress" value="0"></progress><span id="display"></span></td>
<td class="test"><a class="checkBtn checkBtn1" onclick="downloadFile(event, '100Mb.dat')">다운로드</a></td>
<td><a class="pauseBtn pauseBtn1" onclick="stop(1);" value="ACTION">일시정지</a><a class="resumeBtn resumeBtn1" onclick="resume(1);" value="ACTION">다시시작</a></td>
</tr>
</table>
</div>
</body>
</html>
Related
is there something wrong with the code below
Just trying to fix decimal paces for a specific class of td.
need to use only jquery
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<td class="go"> 25.252525
</td>
<script type="text/javascript">
$('.go').each(function() {
return parseFloat($(this).toFixed(2));
}
</script>
</body>
</html>
You need to use .text() to get text from td then use .toFixed() and finally change updated value inside your td i.e : $(this).text(parseFloat($(this).text()).toFixed(2));
Demo Code :
$('.go').each(function() {
$(this).text(parseFloat($(this).text()).toFixed(2)); //change text..
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<table>
<tr>
<td class="go"> 25.252525
</td>
</tr>
<tr>
<td class="go"> 25.2223525
</td>
</tr>
</table>
My JS code looks like this. But when I open the page it says "Uncaught TypeError: Cannot set property 'innerHTML' of null"
I tried to change the NewItem constructor to a function. But VSC keeps saying I should declare it as a class instead. I converted it in the first place because the constructor wasn't working as a function either.
class NewItem {
constructor(name, date, price) {
this.itemName = name;
this.itemDate = date;
this.itemPrice = price;
}
}
const onListItem = new NewItem("John", "Date", "Price");
document.getElementById("demo").innerHTML = onListItem.itemDate;
HTML looks like this
<!DOCTYPE html>
<html lang= "en">
<head>
<link rel="stylesheet" href="ShopListStyle.css">
<meta name="viewport" content="width=device-width" initial-scale=1.0>
<title>Shopping List</title>
</head>
<body>
<script src="ShopListScript.js"></script>
<div id="container">
<div id="inputbox" class="section">
<form id="labels-form">
<label><h2>Shopping List</h2></label>
<input id="labels-name" class="labels-input" type="text" value="Item Name"></input>
<input id="labels-date" class="labels-input" type="text" value="Date of Purchase"></input>
<input id="labels-price" class="labels-input" type="text" value="Item Price"></input>
<button id="labels-button">Add to List</button>
<p id="demo"></p>
</form>
</div>
<div id="shopListBox" class="section">
<!--Need to add a delete button/ Maybe a quantity button down the road-->
<table id="shopList">
<caption><h2>Spending List</h2></caption>
<thead id="table-header">
<tr>
<th class="table-header" id="table-name">name</th>
<th class="table-header" id="table-date">date</th>
<th class="table-header"id="table-price">price</th>
<th class="table-header" id="table-delete">delete</th>
</tr>
</thead>
<tbody id="table-body">
<tr class="newRow">
<td class="new-item" id="item-name">item</td>
<td class="new-item" id="item-date">item</td>
<td class="new-item" id="item-price">item</td>
<td class="new-item"><button class="item-button">Delete</button></td>
</tr>
</tbody>
<tfoot id="table-footer">
<tr>
<td id="item-price-sum" colspan="4" style="width: 100%" >Sum of Prices</td>
</tr>
</tfoot>
</table>
<!--The sum of all the prices will go somewhere here-->
</div>
</div>
</body>
</html>
Your JavaScript code is trying to access this element with id demo (<p id="demo"></p>):
document.getElementById("demo").innerHTML = onListItem.itemDate;
Your script is added at the opening body tag...
<body>
<script src="ShopListScript.js"></script>
...
...which means the demo element does not exist yet.
Solution: Put your script before the closing body tag:
...
<script src="ShopListScript.js"></script>
</body>
</html>
You can also try to set
<script src="ShopListScript.js" defer="defer"></script>
Because javascript will block the DOM rendering, so we should put in the end of
like Peter Krebs's answer:
...
<script src="ShopListScript.js"></script>
</body>
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Game</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script src="script.js"></script>
</head>
<body>
<div class="container">
<table class="table ">
<tr>
<td id="1">a</td>
<td id="2">a</td>
<td id="3">a</td>
<td id="4">a</td>
</tr>
<tr>
<td id="5">a</td>
<td id="6">a</td>
<td id="7">a</td>
<td id="8">a</td>
</tr>
<tr>
<td id="9">a</td>
<td id="10">a</td>
<td id="11">a</td>
<td id="12">a</td>
</tr>
<tr>
<td id="13">a</td>
<td id="14">a</td>
<td id="15">a</td>
<td id="16">a</td>
</tr>
</table>
</div>
</body>
function startFunction() {
var table = document.querySelector('#table');
var table_cells = table.querySelectorAll('td');
}
window.onload = function() {
startFunction();
};
I keep getting an error of "uncaught typeError: cannot read property 'querySelectorAll' of null."
I think this has to do with the fact when I'm calling a function that tries to grab said element node before it exists perhaps?
I'm loading my Javascript file in the <head> section of my HTML file so I added a window.onload function to make sure everything is loaded before the page runs. However, I still keep getting this error.
Take a look at this line in your JavaScript:
var table = document.querySelector('#table');
The pound-sign indicates an ID, and so your javascript is looking for an element with the ID of "table".
But, if you look at your table, it doesn't have an ID; only class.
The solution is to give your <table> an ID of "table" so that the javascript properly finds it:
<table id="table">
The table is missing id attribute. Instead, it has class attribute. Fix by adding id
<table class="table" id="table">
Or modify your query selector to select by class:
var table = document.querySelector('.table');
I got AutoIt to work with my router login page. However for our HP Pro Curve Switch.. I can't get it to work...
#NoTrayIcon
#include <ie.au3>
$Address = "http://10.255.96.2/index.html"
$pwd="mypassword"
$oIE = _IECreate ($Address)
_IELoadWait($oIE)
$oForm = _IEFormGetObjByName ($oIE, "maindata")
for $stuff in $oForm
if $stuff.name = "password" and $stuff.type = "password" then _IEFormElementSetValue ($stuff, $pwd)
If $stuff.value == "Login" and $stuff.type = "submit" Then $stuff.click
Next
exit
I get "H:\loginToSwitch.au3" (10) : ==> Variable must be of type "Object".:
Basically the "maindata" is incorect.
Here is the HTML if I right click on the page and view source:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<meta name=Copyright content="Copyright (c) 2005 HP Networks, Inc. All Rights Reserved.">
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta http-equiv="Pragma" content="no-cache">
<title>HP Networks Web Interface</title>
<script src="/mainjs.js" language=javascript type="text/javascript"></script>
<script language="javascript" type="text/javascript">
//<!--
checkFrame(); // Ensure we are not within a frame
implementLoginFrames('login.html');
document.write('<noframes>');
//-->
</script>
</head>
<body BGCOLOR="#DAE3EB">
<center>
<font color="#008BD1" face="Arial, Helvetica, sans-serif"><B>Please ensure that your browser supports Frames and Javascript, and that they are both enabled.</b></font>
</center>
<script language="javascript" type="text/javascript">
//<!--
document.write('<\/noframes>');
//-->
</script>
</body>
</html>
However, when I use firefox to identify elements... it gives me a completely different code (which is what I got the buttons and textbox info from):
<html>
<head></head>
<frameset framespacing="0" border="0" frameborder="0" rows="80,*">
<frameset framespacing="0" border="0" frameborder="0" cols="*,22"></frameset>
<frame src="login.html" noresize="" name="loginFrame" scrolling="auto">
#document
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head></head>
<body onload="loadConfiguration();">
<script type="text/javascript" language="javascript"></script>
<form onsubmit="return login();" name="tF" method="post" action="login.html">
<table class="container" style="height: 650px">
<tbody>
<tr>
<td class="container">
<div class="container">
<div class="loginbox">
<!--
Login box HTML code here...
-->
<table class="login">
<tbody>
<tr>
<td id="devname" class="hdr style2" style="color: #ffffff; font-family: Arial, Helvetica, sans-serif;" colspan="2"></td>
</tr>
<tr>
<td class="hdr style2" valign="top"></td>
<td class="maindata">
<input id="password" type="password" onkeypress="capsCheck(event);" size="20" name="password" maxlength="16"></input>
<script type="text/javascript" language="javascript"></script>
<input class="button" type="submit" style="position: relative; top: 2;" value="Login"></input>
<br></br>
<span id="passwd" class="default" style="display: none;"></span>
</td>
</tr>
<tr></tr>
<tr></tr>
</tbody>
</table>
<span id="wrong" class="warning" style="display: none;"></span>
<br></br>
<span id="capsmsg" class="warning" style="display: none;"></span>
<br></br>
It is recommended that you use a minimum of
<br></br>
Microsoft® Internet Explorer 5.5 to view the Inter…
<br></br>
<br></br>
<!--
Login box HTML end...
-->
</div>
</div>
</td>
</tr>
</tbody>
</table>
<script type="text/javascript" language="javascript"></script>
</form>
</body>
</html>
</frame>
</frameset>
<noframes></noframes>
</html>
_IEFormGetObjByName() Returns an object variable, not a collection.
Use _IETagNameAllGetCollection($oForm) to list all of the element inside a object.
Edit:
I have looked closely to the html and I see that the password field has ID and NAME attributes. Use _IEGetObjById to get the object of a password field.
#NoTrayIcon
#include <ie.au3>
$Address = "http://10.255.96.2/index.html"
$pwd="mypassword"
$oIE = _IECreate ($Address)
;_IELoadWait($oIE) Not needed because IECreate does wait for page to load by default.
$oPassword = _IEGetObjById($oIE, "password")
_IEFormElementSetValue ($oPassword, $pwd)
$oForm = _IEGetObByName($oIE, "tF")
_IEFormSubmit($oForm)
Is there a command line tool or online service that can convert javascript unicode notation code to utf-8?
E.g. I got this json code, but it is hard to edit in common text editor.
{"name":"leon zhang","city":"\u4e0a\u6d77"}
I want to convert it to:
{"name":"leon zhang","city":"上海"}
You use the below javascript function to convert unicode to utf-8
function encode_utf8( s ){
return unescape( encodeURIComponent( s ) );
}( '\u4e0a\u6d77' )
You can also try it out in firebug console. It works.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>UTF-8 To Unicode</title>
<style type="text/css">
<!--
td {
height: 24px;
line-height: 24px;
}
#content {
margin-top: 2px;
}
-->
</style>
</head>
<script type="text/javascript">
function encodeGB2312(){
var c = document.all.content.value;
var re = /(%)+/g;
var result = escape(c);
document.all.content.value = result.replace(re, "\\");
document.all.content.focus();
document.all.content.select();
}
function clearContent(){
document.all.content.value = "";
document.all.content.focus();
}
</script>
<body>
<h3 align="center">UTF-8 To Unicode</h3>
<table width="600" border="1" cellspacing="0" cellpadding="0" align="center" style="text-align:center;">
<tr>
<td>Input what you want to convert:</td>
<td><input type="text" name="content" id="content" size="50"/></td>
</tr>
<tr>
<td colspan="2">
<input type="button" name="encoding" value="Start Conversion" onclick="encodeGB2312()"/>
<input type="button" name="clear" value=" Cancel" onclick="clearContent();"/></td>
</tr>
</table>
</body>
</html>
This is a sample of convert utf-8 to unicode, do it in turn.