[英]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.