我正在尝试创建bookmarklet for my website以在我的平台上自动分享文章。问题是它没有提交文章。
<div style="margin-left: 15px;"><span class="bookmarklet"><span class="fa fa-bookmark"></span> Get the
<br>
<a title="Drag this link to your bookmark bar. Click the bookmark when you want to submit an article." data-original-title="" class="has-tooltip" onclick="return false;" data-toggle="tooltip" data-placement="bottom" data-title="Drag this link to your bookmark bar. Click the bookmark when you want to submit an article." href="javascript:location.href='http://www.fineconomy.com/submit-articles/?link='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)" style="cursor:move;text-decoration:none;">FinEco Bookmarklet</a>
</span>
</div>
我创建了一个测试用户:
用户名:测试
Pwd: test12345
有什么建议我做错了吗?
感谢您的回复!
更新1
我在页面底部添加了以下javascript。
;(function(win, $) {
if (window.location.pathname.indexOf('submit-articles') > -1) {
$(".maincontent").addClass('content-push-sidebar');
}
})(window, window.jQuery);
此外,我更新了书签:
<span class="bookmarklet"><span class="fa fa-bookmark"></span> Get the<br>
<a title="Drag this link to your bookmark bar. Click the bookmark when you want to submit an article." data-original-title="" class="has-tooltip" onclick="return false;" data-toggle="tooltip" data-placement="bottom" data-title="Drag this link to your bookmark bar. Click the bookmark when you want to submit an article." href="javascript:location.href='http://www.fineconomy.com/submit-articles/?link='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)" style="cursor:move;text-decoration:none;">FinEco Bookmarklet</a></span>
我的问题是我无法向该字段添加主题。
当我关闭submit-article
窗口时,弹出主题的字段:
有关隐藏字段的任何建议吗?
答案 0 :(得分:2)
重述问题以确保理解:
您需要一个书签,当点击该书签时,会将用户带到经济状态并预先填写文章提交表单,其中包含用户碰巧所在网页的网址和标题。
到达fineconomy后,您添加的代码段会通过检查页面网址(在经济上)是否包含“submit-articles”来显示表单,如果确实如此,则基本上会向主要内容div添加一个类使表格出现。
因为您检查自己是否在http://fineconomy.com/submit-articles/页面上,我假设您正在使用某种模板系统,只允许您将脚本添加到某种全局页脚 - 也许是wordpress,如果wp-theme references。
无论如何,我认为隐藏主题字段的原因是有这个css声明:
/* NEW CODE FOR V1.1 */
/** SNIP **/
.selectize-input{
display:none;
}
主题字段是.selectize-input
字段。我不确定为什么风格在那里,但它阻止了该领域的显示。我对你的系统了解不足以说明该声明是否属于那里。
如果它确实属于那里,我想你必须在页面上增加javascript片段以显示组件。像这样:
;(function(win, $) {
if (window.location.pathname.indexOf('submit-articles') > -1) {
$(".maincontent").addClass('content-push-sidebar');
$(".selectize-input").show();
}
})(window, window.jQuery);
尽管如此,你说当表单被解散时会出现该字段,如果某些内容试图切换其可见性$(".selectize-input").toggle();
,就会发生这种情况。这表明提交表单通常是通过某种方法调用显示的,如果是这种情况,建议使用此调用,而不是在上面的代码段中添加content-push-sidebar
类。
如果可能的话,我还会检查是否有办法将代码段放在提交页面上,无需检查“submit-article”的当前网址。它通常会使事情更容易维护,更不容易出错,并且效率更高。