点击按钮后,我在调用以下javascript时遇到问题。 我还需要一个代码来插入按钮,我可以用它调用下面的JS函数。唯一的要求是在单击按钮之前,脚本的结果不应显示在页面中。此外,即使在执行脚本之后,按钮也将保持其位置不变。单击按钮后,页面不应重新加载。生成的Feed应仅作为页面中的一部分在按钮下方运行。
<!-- 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 -->
请快速帮助。
答案 0 :(得分:0)
使用HTML onClick
调用javascript函数。还纠正了javascript并使其可读。请注意,我删除了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 -->