我正在制作一个中等复杂的Bookmarklet,它可以在Chrome中运行得很好,但我无法在Firefox中使用它.当我在Firefox中运行我的Bookmarklet时,它会重定向到仅true在其上显示的新页面.
我已经将原因缩小到一个非常具体的事情:当你将新函数暴露给全局命名空间时,Firefox似乎并不喜欢.
如果是这种情况,您可能对此有更多了解吗?这是否记录在任何地方,以便我可以了解更多信息?关于书签构建的细微差别的资源似乎很少,我找不到任何相关的东西.第二个问题是,是否有任何已知的解决方法.
对于一些例子(记住,测试它们只需将这些代码行复制到Firefox中的书签中.然后在任何页面上运行它们).
重定向书签
javascript:!function(){window.okay={test:function(){}}}();
非重定向书签
javascript:!function(){window.okay={test:!0}}();
有什么想法吗?谢谢!
目前,我计划在Knockout中使用手动订阅来获得我需要的功能.不过,知道这个问题的答案仍然很好.
我想在SVG中创建一个固定在一点的直线.当用户单击并拖动另一个端点时,该端点将跟随其光标.我正在使用snap.svg这个.
我这样做的想法是先画一条线:
var line = paper.line( 300, 250, 450, 150 );
line.attr({
stroke: "#000",
strokeWidth: 5,
strokeLinecap:"round"
});
Run Code Online (Sandbox Code Playgroud)
然后创建一个控制圈,我跟踪拖动事件.在拖动的回调我会更新x2和y2线路的使用性能dx和dy传递的参数.
我注意到的第一件事就是简单地设置导致事情爆炸的属性.我不完全确定我理解为什么会这样,但似乎可能是我的回调在它有机会运行之前被重复调用的情况.然后,当它"赶上"自己时,它会以某种方式超越.我不太确定.
无论如何,通过谷歌搜索我能够确定使用控制圆上的转换属性将允许我模拟默认drag方法:
var move = function(dx,dy) {
// This appends the new transform to the original
this.attr({
transform: this.data('origTransform') + (this.data('origTransform') ? "T" : "t") + [dx, dy]
});
}
// Maybe this saves the current transform if it hasn't happened yet?
var start = function() {
this.data('origTransform', this.transform().local …Run Code Online (Sandbox Code Playgroud) 考虑这样的元组:
type MyTuple = [A, B];
Run Code Online (Sandbox Code Playgroud)
where A和Bboth都有一个名为的属性key.例如,
interface A = {
key: 'sandwiches'
}
interface B = {
key: 'pasta'
}
Run Code Online (Sandbox Code Playgroud)
我希望以下界面:
interface Result {
sandwiches: A;
pasta: B;
}
Run Code Online (Sandbox Code Playgroud)
有没有办法动态地做到这一点?
我想,如果这是可以实现的,它可能看起来像:
type MapTuple<T> = {
[K in keyof T]: T[K]["key"]
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用.
这个问题是逆的打字稿:对象类型到阵列型(元组)
我有以下代码:
public VizCanvas(){
{
this.setBackground(Color.black);
this.setSize(400,400);
}
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,并在黑色背景下显示面板.但是当我实现不做任何操作的paint方法时,颜色会变为默认颜色,即灰色.
我试图设置graphics.setColor()但它没有帮助.
我试图在http://jsfiddle.net/hozey/9dGuc/的 CSS 中添加一个子菜单,但似乎无法掌握它。有人可以帮助这个新手吗?这是 HTML。我想为马 1、2 和 3 制作一个子菜单。
<div class="menu">
<ul>
<!--begin to insert contents-->
<li class="item-first"><a href="http://www.lawsart.com" target="_top">Home</a></li>
<li><a class="current">Portfolio ▼</a>
<ul>
<li><a href="http://www.lawsart.com/Horses1.html" target="_top">Horses 1</a></li>
<li><a href="http://www.lawsart.com/Horses2.html" target="_top">Horses 2</a></li>
<li><a href="http://www.lawsart.com/Horses3.html" target="_top">Horses 3</a></li>
<li><a href="http://www.lawsart.com/Dogs.html" target="_top">Dogs</a></li>
<li><a href="http://www.lawsart.com/People.html" target="_top">People</a></li>
<li><a href="http://www.lawsart.com/Stills.html" target="_top">Stills</a></li>
</ul>
</li>
<li><a href="http://www.lawsart.com/Order.html" target="_top">Order</a></li>
<li><a href="http://www.lawsart.com/Contact.html" target="_top">Contact Me</a></li>
</ul>
</div> <!-- end menu -->
</div>
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止得到的 css:
body {
margin: 0px;
}
#wrapper {
border: px solid black;
margin: 1em auto;
font-family: Arial,Helvetica,sans-serif; …Run Code Online (Sandbox Code Playgroud) bookmarklet ×1
css ×1
firefox ×1
graphics ×1
java ×1
java-2d ×1
javascript ×1
menu ×1
snap.svg ×1
submenu ×1
svg ×1
typescript ×1