简体   繁体   English

单击按钮后如何调用javascript函数?

[英]How to call javascript function after click of a button?

Hi i'm having problem in calling the below javascript after click of a button.嗨,我在单击按钮后调用下面的 javascript 时遇到问题。 I also need a code to insert button with which I can call the below JS function.我还需要一个代码来插入按钮,我可以用它来调用下面的 JS 函数。 The only requirement is that the result of the script should not display in the page before click of a button.唯一的要求是在单击按钮之前脚本的结果不应显示在页面中。 Further, the button will stay at its position unchanged even after the execution of the script.此外,即使在执行脚本后,按钮仍将保持不变。 The page shouldn't reload after clicking on the button.单击按钮后不应重新加载页面。 The resultant feed should run below the button only as a section in the page.结果提要应仅作为页面中的一个部分在按钮下方运行。

    <!-- start feedwind code --><script type="text/javascript">document.write('\x3Cscript type="text/javascript" src="' + ('https:' == document.location.protocol ? 'https://' : 'http://') + 'feed.mikle.com/js/rssmikle.js">\x3C/script>');</script><script type="text/javascript">(function() {var params = {rssmikle_url: "http://news.google.co.in/news?pz=1&cf=all&ned=in&hl=en&topic=n&output=rss",rssmikle_frame_width: "400",rssmikle_frame_height: "500",frame_height_by_article: "0",rssmikle_target: "_blank",rssmikle_font: "Arial, Helvetica, sans-serif",rssmikle_font_size: "12",rssmikle_border: "off",responsive: "off",rssmikle_css_url: "",text_align: "left",text_align2: "left",corner: "off",scrollbar: "on",autoscroll: "on_mc",scrolldirection: "up",scrollstep: "3",mcspeed: "30",sort: "New",rssmikle_title: "on",rssmikle_title_sentence: "Indian Latest News - As it happens",rssmikle_title_link: "",rssmikle_title_bgcolor: "#0066FF",rssmikle_title_color: "#FFFFFF",rssmikle_title_bgimage: "",rssmikle_item_bgcolor: "#FFFFFF",rssmikle_item_bgimage: "",rssmikle_item_title_length: "55",rssmikle_item_title_color: "#0066FF",rssmikle_item_border_bottom: "on",rssmikle_item_description: "on",item_link: "on",rssmikle_item_description_length: "150",rssmikle_item_description_color: "#666666",rssmikle_item_date: "gl1",rssmikle_timezone: "Etc/GMT",datetime_format: "%b %e, %Y %l:%M:%S %p",item_description_style: "text+tn",item_thumbnail: "full",item_thumbnail_selection: "auto",article_num: "15",rssmikle_item_podcast: "off",keyword_inc: "",keyword_exc: ""};feedwind_show_widget_iframe(params);})();</script><div style="font-size:10px; text-align:center; width:350px;"><a href="http://feed.mikle.com/" target="_blank" style="color:#CCCCCC;">RSS Feed Widget</a><!--Please display the above link in your web page according to Terms of Service.--></div><!-- end feedwind code -->

Quick help needed please.需要快速帮助。

Using the HTMLs onClick to call a javascript function.使用 HTML onClick调用 javascript 函数。 Also corrected the javascript and made it readable.还更正了 javascript 并使其可读。 Note I have removed the document.write and replace with the https link, if your site uses both http and https, you will need to revert back to the document.write注意我已经删除了document.write并替换为 https 链接,如果您的站点同时使用 http 和 https,您将需要恢复到document.write

 <button onClick='onClickFunc();'> Run script </button> <!-- start feedwind code --> <script type="text/javascript" src="https://feed.mikle.com/js/rssmikle.js"></script> <script type="text/javascript"> function onClickFunc() { var params = { rssmikle_url: "http://news.google.co.in/news?pz=1&cf=all&ned=in&hl=en&topic=n&output=rss", rssmikle_frame_width: "400", rssmikle_frame_height: "500", frame_height_by_article: "0", rssmikle_target: "_blank", rssmikle_font: "Arial, Helvetica, sans-serif", rssmikle_font_size: "12", rssmikle_border: "off", responsive: "off", rssmikle_css_url: "", text_align: "left", text_align2: "left", corner: "off", scrollbar: "on", autoscroll: "on_mc", scrolldirection: "up", scrollstep: "3", mcspeed: "30", sort: "New", rssmikle_title: "on", rssmikle_title_sentence: "Indian Latest News - As it happens", rssmikle_title_link: "", rssmikle_title_bgcolor: "#0066FF", rssmikle_title_color: "#FFFFFF", rssmikle_title_bgimage: "", rssmikle_item_bgcolor: "#FFFFFF", rssmikle_item_bgimage: "", rssmikle_item_title_length: "55", rssmikle_item_title_color: "#0066FF", rssmikle_item_border_bottom: "on", rssmikle_item_description: "on", item_link: "on", rssmikle_item_description_length: "150", rssmikle_item_description_color: "#666666", rssmikle_item_date: "gl1", rssmikle_timezone: "Etc/GMT", datetime_format: "%b %e, %Y %l:%M:%S %p", item_description_style: "text+tn", item_thumbnail: "full", item_thumbnail_selection: "auto", article_num: "15", rssmikle_item_podcast: "off", keyword_inc: "", keyword_exc: "" }; feedwind_show_widget_iframe(params); } document.write(" <button onClick = 'onClickFunc();' > Run script < /button>"); </script> <div style="font-size:10px; text-align:center; width:350px;"> <a href="http://feed.mikle.com/" target="_blank" style="color:#CCCCCC;"> RSS Feed Widget</a> <!--Please display the above link in your web page according to Terms of Service.--> </div> <!-- end feedwind code -->

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 按钮单击事件ASP后如何调用javascript函数 - How to call javascript function after button click event ASP 单击功能区中的按钮时如何调用JavaScript函数 - How to call javascript function on click of button in ribbon 如何在不单击按钮的情况下调用javascript函数? - How to call javascript function without button click? 如何在asp.net中按钮点击事件调用之前和之后调用javascript函数 - How to call a javascript function before and after button click event call in asp.net 单击 html 按钮上的 javascript 函数后调用服务器事件 - call server event after javascript function on html button click 如何在按钮单击时从JavaScript函数调用Ajax? - How to call ajax from a javascript function on button click? 如何在Button上单击JavaFX WebView调用JavaScript函数? - How to call a JavaScript function from a JavaFX WebView on Button click? 如何在单选按钮上调用Javascript函数单击不在焦点上 - How to call Javascript Function on radio button click not on focus 如何在一个链接按钮上调用javascript和codebehind功能点击? - how to call javascript and codebehind function on one link button click? 如何从 svelte 在 javascript 中单击按钮时调用异步函数? - How to call an async function on button click in javascript from svelte?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM