xxx.jsの中身 function SetText(){ var path = "../text/aaa.txt"; var file = new File(path); file.open("r"); document.write(file.readln()); file.close(); } で1行分表示する感じ。これをindex.htmlで呼び出してる。
<script src="https://www.google.com/jsapi"></script> <script> google.load("feeds", "1"); function initialize() { var feed = new google.feeds.Feed(‘URL/index.rdf'); feed.setNumEntries(100); feed.includeHistoricalEntries(); feed.load(function(result) { if (!result.error) { var container = document.getElementById('feed'); for (var i = 0; i < result.feed.entries.length; i++) { var entry = result.feed.entries[i]; var link = document.createElement("a"); link.href = entry.link; link.appendChild(document.createTextNode(entry.title)); var li = document.createElement("li"); li.appendChild(link); container.appendChild(li); } } }); } google.setOnLoadCallback(initialize); </script>
Error: An img element must have an alt attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images. From line 7, column 4; to line 7, column 20 <body>?<p><img src="a.gif"></p>?<
・https://html5.validator.nu/ Error: An img element must have an alt attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images. From line 7, column 4; to line 7, column 20 <body>?<p><img src="a.gif"></p>?<
・https://validator.w3.org/ Error: An img element must have an alt attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images. From line 7, column 4; to line 7, column 20 <body>?<p><img src="a.gif"></p>?<
・http://www.onlinewebcheck.com/ 13] In most cases HTML5 requires that the "alt" attribute be used with the "img" element. The "alt" attribute is critical for accessibility and useful for SEO. It may only be omitted when no alternative text is available and none can be made available. NOTE: Alternate text should not change the meaning of the page when it is used to replace the image, and it should not be supplemental text, like a caption, title, or legend (because it's replacement text; consider the "title" attribute for supplemental text). It should also not repeat information that is provided in the prose next to the image. <p><img src="a.gif"></p>
>>122 もう一度聞きますが、「JavaScript が出力するHTML」とはどんな機能で出力させているのでしょう? JavaScript が出力する HTML は構築済みの DOM からそれらしき HTML 文字列を出力しているだけなので HTML の文法規則にとらわれる必要はないと思うのですが… JavaScript で出力した HTML を innerHTML で代入するなら気にする必要がありますが、それは運用次第で回避可能だと思います
--- 一応聞きますが、あなたが書いているのは HTML5 (HTML Living Standard) で間違いないでしょうか alt 属性値を省略可能(省略可能なのは alt 属性値だけで alt 属性は省略不可)なのは HTML5 だけです
また、それは本当に alt 属性値を省略可能な状況でしょうか HTML5 では alt 属性値を省略可能な仕様にしましたが、それは「文脈上、省略可能な場合がある」だけで機械的にそれを判断することは出来ません <!DOCTYPE html><title>test</title><img src="img07.jpg" alt=""> は https://validator.w3.org/ でエラーを出力しませんが、alt="" が本当に正しいかどうかは人間の目で見て判断するしかありません >>105を見る限りでは <img src="img07.jpg" alt="7月"> と書くべきと思えますが、どうでしょう? HTML5 で alt 属性値を省略可能なケースは仕様書に細かく記載されていますので一読してみてください http://momdo.github.io/html5/embedded-content-0.html#alt
figure要素内でなくともtitleがあればいいし、もっと言えば私的な範囲であれば無くても良いるーるもある まとめるとこれ >>If the src attribute is set and the alt attribute is not >>The image might be a key part of the content, and there is no textual equivalent of the image available. https://html.spec.whatwg.org/#the-img-element:attr-img-src-15
var shuffle = ary => { var len = ary.length do { var ra = [...new Set(crypto.getRandomValues(new Uint32Array(len)))] } while ( b.length !== len ) return [...ra].sort().map( (v, i) => ary[ra.indexOf(v)] ) }
「TypeError: undefined is not an object (evaluating foo(a))」のようなエラーを見かけますが、 「evaluating foo(a)」の部分は、どうやって出力しているのでしょうか?
function foo(a) { throw new TypeError('undefined is not an object'); } foo(b); // (理想)TypeError: undefined is not an object (evaluating foo(b)) foo(c); // (現実)TypeError: undefined is not an object
>>253 の言うように「undefined is not an function」が、 「a is not an function」と出力されてどの変数か分かるようになりましたが、 ユーザー定義のエラーでは再現できないようです。
function foo(a) { var undefined; if (a === undefined) { throw new TypeError('undefined is not an object'); } } var b; foo(b); // TypeError: undefined is not an object (evaluating foo(b))
function foo(a) { var undefined; if (a === undefined) { throw new TypeError('undefined is not an object (evaluating foo(a))'); } } var b; foo(b); // TypeError: undefined is not an object (evaluating foo(a))
>>255 結局、"evaluating foo(a)" の再現コードは何だったのでしょう? >>252で書いたように私の手元では再現できませんでしたが、あなたの環境では再現できるのでしょうか。 再現できるのなら再現条件も特定可能だと思うのですが。 正直、該当コードには throw new TypeError(a + ' is not an Object (evaluating foo(a))') と書かれているような気もしますね。
>>257 >>255 を読んでいただければ、意図していることが伝わると思ったのですが、どうも説明が足りなかったのか勘違いされているようです。 私がやりたいことは、foo(a);と呼ばれたら「TypeError: undefined is not an object (evaluating foo(a))」、foo(b);なら「TypeError: undefined is not an object (evaluating foo(b))」のように呼び出し元のコードを出力させたいのです。
(function (undefined) { var b; foo(b); function foo(a) { if (a === undefined) { var code = arguments.callee.caller.toString().match(/foo\(.*\)/)[0]; throw new TypeError('undefined is not an object (evaluating ' + code + ')'); } } })();
260 :252:2015/08/06(木) 21:55:33.81 ID:tK2OlZv6
>>259 > >>251 のコードは、「evaluating foo(a)」が出力されなくて当然です。 私は>249で "「TypeError: undefined is not an object (evaluating foo(a))」を再現するためのコード" を求めましたが、あなたは再現不可能なコードを掲示していたのですね。 >>246で "「TypeError: undefined is not an object (evaluating foo(a))」のようなエラーを見かけますが、" と書いているのであなたが見たことがあるサイトなりコードなりを開示していただけるものと思っていました。 私は見たことがありません。再現できなければ、検証できません。
// グローバル変数 var inited = 0; //初期化したかどうかのフラグ var started = 0; //開始したかどうかのフラグ var questionNumber = 0; // 現在の問題数 var questionDate = 0; // 出題時の時間 var startDate = 0; // 開始時の時間 var hitNumber = 0; // 現在の正解数 var p = 0; // 一個目の数字 var q = 0; // 二個目の数字 var kigou = ""; //演算子
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari Basic support Not supported 38 (38) Not supported Not supported Not supported Available in workers Not supported 38 (38) Not supported
あの、関連して質問なのですが、このようにしてbuttonにclickイベントを割り当てることは出来たのですが、 その後、ulに新しいbuttonを var ul = document.getElementById('ul_ID'); var li = document.createElement('li'); ul.appendChild(li); li.innerHTML = '<button>新しいボタン</button>'; で追加したら、このボタンにはclickイベントを割り当てていないにもかかわらず 既存のボタンと同じイベントハンドラ関数が呼ばれるんですが、 そういう事って有り得ますか? それとも私何かおかしな事やっていますか?
var webdriver = require("selenium-webdriver"); var driver = new webdriver.Builder().withCapabilities(webdriver.Capabilities.chrome()).build(); driver.get("http://server/path/"); driver.findElements(webdriver.By.tagName("a")).then(function (elements) { for (var i = 0; i < elements.length; i++) { console.log(elements[i].getAttribute("href")); } });
var reader = new FileReader; とかの、次世代のhtml5対応ブラウザに実装された機能の話題が メインにJavascriptスレが進行していくと思ったら、 なんか、初心者の質問が結構多いな。 そういや、もうHTML5ってさ、Javascriptだけで、ライブラリ使用せずに RPGゲームとか作れるんだっけ?
他ページにも存在するのは id でも class でも変わらないし、CSS でも考えるべき事だ id を危険視する理由にはならない
567 :557:2015/09/07(月) 23:15:18.30 ID:c1NuIfeD
あなたが複数のページで>>564の機能を使いたいと思ったのなら、あなたは同一IDを持つ同じHTML(>>564のHTML)をコピペして使いまわしても良い URLが変わったからといって、#Calc-group1, #Calc-group2 のように id 属性値をユニークな名前を命名し直す必要はない id も class も考え方は同じであり、同じ構造を期待するなら同じ名前を付ければ良い
>>752 document.body.appendChild(document.createElement('p')); 上記コードが実行された場合、製作者は body 要素ノードに p 要素ノードが挿入された事を「知って」います。 ですので、JavaScript を無効化するには p 要素ノードを削除すればいい事も「知って」いるはずです。 全てのコードに対して何を実行したかを把握し、管理して下さい。