简体   繁体   English

为什么Pinterest代码会更改浏览器中显示的页面(URL)?

[英]Why does the Pinterest code change the page (URL) displayed in the browser?

So I have spent a long time trying to find a Pinterest Pin It button that has both a counter AND allows me to choose any image from the page when I click on it. 所以我花了很长时间试图找到一个既有计数器又允许我单击该页面上的任何图像的Pinterest Pin It按钮。

The Pinterest code supplied by Pinterest requires you to specify a specific image to be shared, but it has a count. Pinterest提供的Pinterest代码要求您指定要共享的特定图像,但是它具有计数。

The Pinterest browser button can be adopted to use on a page and will bring up a javascript window allowing the user to choose any suitable image on the page, but it has no count. 可以采用Pinterest浏览器按钮在页面上使用,它将弹出一个javascript窗口,允许用户在页面上选择任何合适的图像,但是没有计数。

I've been playing around and searching and am very close. 我一直在玩耍并搜索,并且非常接近。 I have this code which is some of my own and some I've found on other sites: 我有以下代码,这是我自己的代码,也可以在其他网站上找到:

<a class='pin-it-button' count-layout='horizontal' href='http://pinterest.com/pin/create/button/?url={Encoded URL of Current Page}'>Pin It</a>
<a href='javascript:void(run_pinmarklet())' style='margin-left:-93px; width:43px; height:20px; display:inline-block;'/></a>
<script src='http://assets.pinterest.com/js/pinit.js' type='text/javascript'/>
<script type='text/javascript'>
function run_pinmarklet() {
var e=document.createElement('script');
e.setAttribute('type','text/javascript');
e.setAttribute('charset','UTF-8');
e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r=' + Math.random()*99999999);
document.body.appendChild(e);
}
</script> 

What this is doing is basically cheating by having the count button but then putting the code that lets a user choose an image an an element directly on top of the original button. 这基本上是在通过使用计数按钮来作弊,然后将使用户选择图像和元素的代码直接放在原始按钮的顶部。 A user thinks he is clicking on the Pin It button but is clicking on an that runs the javascript run_pinkarklet(). 用户认为自己正在单击“固定”按钮,但是单击的是运行javascript run_pinkarklet()的。

This works, however after I get the pop-over to choose an image, and I do choose the image, it then gets inserted into a pop-up window to complete the pinning, which works- but in the mean time the main page in the browser reloads. 此方法有效,但是在我获得弹出窗口以选择图像后,并且确实选择了图像,然后将其插入到弹出窗口中以完成固定,此操作有效,但与此同时,浏览器重新加载。 It doesn't reload the original page but it reloads the main URL of the current folder. 它不会重新加载原始页面,但会重新加载当前文件夹的主URL。

Example- suppose the page I am pinning is: http://www.example.com/folder1/page1.php 示例-假设我固定的页面为: http : //www.example.com/folder1/page1.php

It reloads to- http://www.example.com/folder1/ 它会重新加载到-http ://www.example.com/folder1/

I can't find any way to stop this reloading or to get it to at least reload the source page. 我找不到停止这种重新加载或至少使其重新加载源页面的任何方法。

I've confirmed this behavior on latest Chrome and Firefox. 我已经在最新的Chrome和Firefox上确认了此行为。

Any ideas? 有任何想法吗?

Pinterest的Widget构建器现在支持any image选项。

将onclick事件中的URL值设置为cookie变量。您可以访问cookie值,使用cookie值并重定向页面。

javascript:void((function(){var%20e = document.createElement('script'); e.setAttribute('type','text / javascript'); e.setAttribute('charset','UTF-8' ); e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r ='+ Math.random()* 99999999); document.body.appendChild(e)}) ());

暂无
暂无

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

相关问题 如何在不离开页面的情况下更改浏览器中显示的URL - How to change the URL displayed in the browser without leaving the page 为什么在浏览器中调用并显示时,存储在 localStorage 中的 HTML 会发生变化? - Why does HTML stored in localStorage change when recalled and displayed in the browser? 为什么jquery代码块中的“ return!1”会导致链接到页面另一部分的定位标记的URL不变? - Why does “return !1” in a jquery code block cause the url not to change for an anchor tag linked to another part of the page? 动态更改Pin It(Pinterest)按钮的网址 - Dynamically change thr URL of the Pin It (Pinterest) button 为什么我的代码会更改页面中的所有 p 标签? - Why does my code change ALL the p tags in my page? 如何在不重新加载页面的情况下更改浏览器 URL? - How to change the browser URL without reload the page? Facebook如何更改浏览器地址栏中的URL而不需要重新加载页面或使用#或? - How does Facebook change the URL in the browser's address bar without page reload or use of # or? 回击浏览器以返回反应页面不会导致页面上的任何代码运行 - 为什么? - Hitting back on browser to return to a react page does not cause any code on the page to run - why? 更改url以反映用Javascript隐藏/显示的页面上的内容 - change url to reflect content on the page hidden / displayed with Javascript 当我将 Tableau 示例中的 URL 更改为另一个 URL 时,为什么我的代码会中断? - Why does my code break when I change the URL in the Tableau sample to another URL?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM