• ベストアンサー

<a return false;>について

Attribute return not allowed on element a at this point.とバリデートで出ます。 クリックした際に、飛ばないようにつけているのですが、下記のようにHTMLには記載してはいけないのでしょうか? <a return false;> スライドショーを進ませるボタンです。 JSのほうにつけるべきなのでしょうか?

noname#226032
noname#226032
  • HTML
  • 回答数2
  • ありがとう数2

質問者が選んだベストアンサー

  • ベストアンサー
  • bya00417
  • ベストアンサー率35% (56/158)
回答No.2

「<a return false;>」なんて書き方はHTMLのルールに反しているので、普通は「<a href="javascript:void(0);">」って書きますね。 これで、aタグとしての動作は無効になります。

noname#226032
質問者

お礼

<a return false;>は間違っているのですね。 <a href="javascript:void(0);">と書けば飛ばないのですね

その他の回答 (1)

  • chie65535
  • ベストアンサー率43% (8526/19383)
回答No.1
noname#226032
質問者

お礼

http://qiita.com/shuntaro_tamura/items/26f8186d4111364918eb こちらを見るとsnsボタンにも同じような記述がありますがこれは良いのですね。

noname#226032
質問者

補足

<script type="text/javascript"> function blank_check() { if (document.getElementById('name').value == "") { alert("ニュウリョクーヽ(゜∀゜)ノ ニュウリョク-ヽ(゜∀゜)ノ"); return false; } else { return true; } } </script> 書いてあるのでJSのみに書くべきということでしょうか?

関連するQ&A

  • 勝手に onClick="return (false);"が付いてしまう

    こちらで作成したHTMLを、先方にメールで送信すると、 何故か<a>タグのすべてに  onClick="return (false);" が付いてしまうようです。 どちらもWindows XP Outlook 2003です。 ファイルは、htmlをzip形式で圧縮して送付しています。 圧縮しないで送った場合も同じでした。 一体何が原因でこうなってしまうのでしょうか? 回避する方法はありますか。 よろしくお願いいたします。

  • onclick属性を使ってreturn false

    リンクを設置するにあたり、SEOを意識しつつ、かつ、ウインドウサイズを指定したい為、onclick属性を使って、下記のような記述してみました。 <a href="link.html" onclick="window.open(this.href,'nullwin','width=500,scrollbars=yes');return false;">リンク</a> これだと、FireFoxでは、開いた別窓にスクロールバーが表示されません。 何かいい方法は無いでしょうか?

  • onsubmitイベントにfalseを返してもsubmitする

    以下のようなコードでフォームを制御したいのですが、戻り値にfalseを返しているのにフォーム送信されてしまいます。 chekData はDB(mysql)にアクセスして重複チェックするだけのものです。 firefoxのエラーコンソールでは以下のようなエラーを出しますが意味がよくわかりません。 エラー: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://192.168.49.128/js/scripts.js :: anonymous :: line 52" data: no] ソースファイル: http://192.168.49.128/js/scripts.js 行: 52 ---------------------- Javascript ----------------------------- function checkData(vender) { ajax.open("GET", "chkDvl.php?dvl=" + encodeURI(vender),true); ajax.onreadystatechange = function() { <<<< 問題の52行目 if (ajax.readyState == 4 && ajax.status == 200) { var res = decodeURI(ajax.responseText); if (res != 0) { window.alert(vender + " " + res + "は既に登録済です"); return false; }else{ return true; } } } ajax.send(null); } ----------------------------- HTML --------------------------- <form action="test.php" method="post" onsubmit="return checkData(this.dvl.value)"> <input name="dvl" type="text" /> <input name="button" type="submit" value="送信" /> </form> ちなみに別のソースの非同期通信を使用しないものはsubmitの制御はできています。 よろしくお願いいたします。

  • リターンメールにつきまして

    仕事でメールを送信する機会(パソコン)が多いのですが、最近リターンメールが増えているように思います。 相手先は、メールアドレスを変更していないのにリターンメールが返ってくるのです。何か解決方法はありますでしょうか? リターンメールの文面は、下記のような内容です。 This Message was undeliverable due to the following reason: Your message was not delivered because the destination computer was not reachable within the allowed queue period. The amount of time a message is queued before it is returned depends on local configura- tion parameters. Most likely there is a network problem that prevented delivery, but it is also possible that the computer is turned off, or does not have a mail system running right now. Your message was not delivered within 0 days and 2 hours. Host yahoo.co.jp is not responding. The following recipients did not receive this message: <送信先のメールアドレス> Please reply to <Postmaster@odn.ne.jp> if you feel this message to be in error. ちなみに、メールソフトはwindows mailです。 osはvistaで、プロバイダーはodnです(odoの送信サーバを使っています) ご教示宜しくお願い致します。

  • requireでreturnを使いたいのですが・・・

    お世話になります。 sub a{ if (-e "./a.cgi"){ repuire "./a,cgi"; } ... } としてa.cgiのなかにreturn関数を入れ、もしa.cgiが存在するならサブルーチンを終了させたいのですがdid not return a true value atエラーが出ました。 戻り値を1としたらエラーは消えましたが...の部分が実行されました。 どなたか解決方法お分かりになる方いましたらご教示お願い致します。

    • ベストアンサー
    • Perl
  • 何がダメなのかわからない

    http://validator.w3.org/check?uri=referer で自分のサイトを見てみたら、 62 Errors, 3 warning(s) となり、たくさんのエラーに驚きました。 ただなぜエラーになるのかわからない部分があります。 例えば、 <body text="gray" link="#808080"> がエラーとなっていますが、何がいけないのでしょうか? --------------------------------------------------------- Line 10, Column 12: there is no attribute "TEXT" <body text="gray" link="#808080"> ✉ You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead). This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information. How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash. --------------------------------------------------------- と書いてあります。

    • ベストアンサー
    • HTML
  • HTML5のバリデートで下記のエラーが出ました。

    HTML5のバリデートで下記のエラーが出ました。 HTML5のバリデータは日本語の物はまだないのでしょうか? 実務ではどれくら、突っ込まれますか? 下記を全部対応しろと言われますか? ・ Warning No Character Encoding Found! Falling back to UTF-8. None of the standards sources gave any information on the character encoding labeling for this document. Without encoding information it is impossible to reliably validate the document. As a fallback solution, the "UTF-8" encoding was used to read the content and attempt to perform the validation, but this is likely to fail for all non-trivial documents. Read the FAQ entry on character encoding for more details and pointers on how to fix this problem with your document. ソースには下記のようにちゃんと文字コードはしていています。 バリデートの問題でしょうか? <!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> ・Unable to Determine Parse Mode! => 解析モードを決定する事が出来ません! これは、実務でも無視して良いのでしょうか?良く分かりません。 ・No DOCTYPE found! Checking with default HTML 4.01 Transitional Document Type. No DOCTYPE Declaration could be found or recognized in this document. This generally means that the document is not declaring its Document Type at the top. It can also mean that the DOCTYPE declaration contains a spelling error, or that it is not using the correct syntax. The document was checked using a default "fallback" Document Type Definition that closely resembles “HTML 4.01 Transitional”. HTML5で作っているのですが、HTML 4.01 Transitionalドックタイプ宣言がないと言っているのでしょうか? ・ Info No Character encoding declared at document level No character encoding information was found within the document, either in an HTML meta element or an XML declaration. It is often recommended to declare the character encoding in the document itself, especially if there is a chance that the document will be read from or saved to disk, CD, etc. <meta charset="utf-8"> があるので無視して良いのでしょうか? ・他にも下記のように終了タグがないようなことをいっていますが、終了タグはあります。 良くあるエラーなのでしょうか? Line 1, Column 913: end tag for "HTML" which is not finished … your browser or use a browser with Javascript support</noscript></body></html> Line 1, Column 75: required attribute "TYPE" not specified …cript" src="/aes.js" ></script><script>function toNumbers(d){var e=[];d.replac… ・Error Line 1, Column 12: document type does not allow element "BODY" herebody の位置は間違えていないと思うのですが、改善点があるのですか? ソース  </head> <body class="top-body"> <div class="container"> ・ Line 1, Column 1: no document type declaration; implying "<!DOCTYPE HTML SYSTEM>" バリデータがおかしいのでしょうか? ソース <!DOCTYPE html> <html lang="ja"> <head> ・ Line 1, Column 12: document type does not allow element "BODY" here <html><body><script type="text/javascript" src="/aes.js" ></script><script>func… The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed). バリデータがおかしいのでしょうか? ソース  </head> <body class="top-body"> <div class="container">

    • ベストアンサー
    • HTML
  • 個別では動く、javascriptのエラー

    こちらで良いのか悩みましたが..... blogやHPを作った事があるというだけで、webshopの作りを友人にお願いされた初心者です。 更新履歴用にFeed2JS、商品画像を表示する為にmootools、lightbox2をお借りして 設置までは何とか行う事が出来、個別ではちゃんと動いているのですが、同じページではどちらかが動かなくなってしまいました。 ブラウザにエラーコンソールを付けてみた所、mootoolsとrssにエラーがあると表示されていて、 どの行がエラーなのかは分かりましたが、情けない話ですが何がエラーなのかが分かりません。 javascriptは見よう見まねで設置しており、コードの書き換えなどは画像サイズを変更するぐらいがやっとです。 ネットや辞書で調べてみましたが、分からないまま弄ると余計におかしな事になり、怖くなってきました。 周りに詳しい人もおらず、困ってしまいましたので、検索でみつけたこちらでお伺いする事にした次第です。 エラー表示されるのは $(document).ready( function(){ $('.rss-items').innerfade({ animationtype: 'slide', speed: 750, timeout: 6000, type: 'sequence', containerheight: '1em' }); $('ul#portfolio').innerfade({ speed: 1000, timeout: 5000, type: 'sequence', containerheight: '220px' }); $('.fade').innerfade({ speed: 1000, timeout: 6000, type: 'random_start', containerheight: '1.5em' }); $('.adi').innerfade({ speed: 'slow', timeout: 5000, type: 'random', containerheight: '150px' }); }); の3行目 $('.rss-items').innerfade({ 長いので直接アドレスを貼ります http://pretto.kilo.jp/cos-pretto/js/mootools-1.2-core.js 345行目 Fx.Slide=new Class({Extends:Fx,options:{mode:'vertical'},initialize:function(a,b){this.addEvent('complete',function(){this.open=(this.wrapper['offset'+this.layout.capitalize()]!=0);if(this.open&&Browser.Engine.webkit419)this.element.dispose().inject(this.wrapper)},true);this.element=this.subject=$(a);this.parent(b);var c=this.element.retrieve('wrapper');this.wrapper=c||new Element('div',{styles:$extend(this.element.getStyles('margin','position'),{'overflow':'hidden'})}).wraps(this.element);this.element.store('wrapper',this.wrapper).setStyle('margin',0);this.now=[];this.open=true},vertical:function(){this.margin='margin-top';this.layout='height';this.offset=this.element.offsetHeight},horizontal:function(){this.margin='margin-left';this.layout='width';this.offset=this.element.offsetWidth},set:function(a){this.element.setStyle(this.margin,a[0]);this.wrapper.setStyle(this.layout,a[1]);return this},compute:function(a,b,c){var d=[];var x=2;x.times(function(i){d[i]=Fx.compute(a[i],b[i],c)});return d},start:function(a,b){if(!this.check(arguments.callee,a,b))return this;this[b||this.options.mode]();var c=this.element.getStyle(this.margin).toInt();var d=this.wrapper.getStyle(this.layout).toInt();var e=[[c,d],[0,this.offset]];var f=[[c,d],[-this.offset,0]];var g;switch(a){case'in':g=e;break;case'out':g=f;break;case'toggle':g=(this.wrapper['offset'+this.layout.capitalize()]==0)?e:f}return this.parent(g[0],g[1])},slideIn:function(a){return this.start('in',a)},slideOut:function(a){return this.start('out',a)},hide:function(a){this[a||this.options.mode]();this.open=false;return this.set([-this.offset,0])},show:function(a){this[a||this.options.mode]();this.open=true;return this.set([0,this.offset])},toggle:function(a){return this.start('toggle',a)}}); です。 マヌケな質問かもしれませんが、参考になるページだけでも教えて頂けると凄く嬉しいです。

  • is not a functionというエラー

    jqueryのスクリプトを書いていたところ $(function () { var wrapper = $("#main"); var wrapperWidth; var blocks = []; NewBlocks(blocks, wrapper.children()); function NewBlocks(blocks, elements) { for (var i = 0; i < elements.length; i++) { var element = elements[i]; var block = new Block(element); blocks.push(block) } } function Block(element) { this.element = element; element.style.margin = "10px"; this.init(); } Block.prototype = { init: function () { this.width = this.element.offsetWidth; this.height = this.element.offsetHeight; } } }); 上記スクリプトを実行すると「this.init is not a function」というエラーが出てしまいます。 一体何をどう間違っているせいでエラーが出るのか、どうかご教授いただけますでしょうか。

  • modalboxで表示したページでのcssについて

    お世話になります、 modalboxで <a href="**.html" title="//..//" onclick="Modalbox.show(this.href,{title: this.title}); return false;">modalBox</a> で開いたページにCSSはきかないのでしょうか? 開くページを単体で見るとCSSを見てるみたいなのですが、 よろしくお願いいたします。