首页 \ 问答 \ Facebook和Twitter分享按钮中的自定义URL(Custom URL in facebook and twitter share button)

Facebook和Twitter分享按钮中的自定义URL(Custom URL in facebook and twitter share button)

我想在我的应用程序中单击共享按钮时共享特定链接。 Facebook分享按钮snipet

<a href="#" 
  onclick="
    window.open(
      'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 
      'facebook-share-dialog', 
      'width=626,height=436'); 
    return false;">
  Share on Facebook
</a>

我如何输入我的自定义网址?


I want to share a particular link when clicked on a share button in my app. Facebook share button snipet

<a href="#" 
  onclick="
    window.open(
      'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 
      'facebook-share-dialog', 
      'width=626,height=436'); 
    return false;">
  Share on Facebook
</a>

How do i input my custom url?


原文:https://stackoverflow.com/questions/18596581
更新时间:2023-06-05 22:06

最满意答案

我猜你在public/目录中有一个名为index.html的文件,这是在请求/时会得到的文件,因为这是express.static()默认执行的操作。

您可以禁用该行为,因此请求将传递给您的/ handler:

app.use(express.static(path.join(__dirname, 'public'), { index : false }));

在此处记录

或者,您可以通过在静态中间件之前声明请求来确保请求命中/ handler:

app.get('/', function (req, res, next) {
  console.log('I'm trying to log this string');
  // make sure to end the response, to prevent hanging requests.
  res.end();
});

app.use(express.static(path.join(__dirname, 'public')));

I'm guessing that you have a file called index.html in the public/ directory, which is the one that will get served when requesting /, because that's what express.static() does by default.

You can disable that behaviour, so the request will be passed to your / handler:

app.use(express.static(path.join(__dirname, 'public'), { index : false }));

This is documented here.

Alternatively, you can make sure that the request hits the / handler by declaring it before the static middleware:

app.get('/', function (req, res, next) {
  console.log('I'm trying to log this string');
  // make sure to end the response, to prevent hanging requests.
  res.end();
});

app.use(express.static(path.join(__dirname, 'public')));

相关问答

更多
  • IIS团队网站上有一篇博客文章,现在解释如何在IIS Express上启用远程连接 。 这是该帖子的相关部分总结: 在Vista和Win7上,从管理提示符中运行以下命令: netsh http add urlacl url=http://vaidesg:8080/ user=everyone 对于XP,首先安装Windows XP Service Pack 2支持工具。 然后从管理提示符运行以下命令: httpcfg set urlacl /u http://vaidesg1:8080/ /a D:(A;; ...
  • 事实证明,我在发布的对象上设置了错误的内容类型。 需要设置为: application/json; charset=UTF-8 Turns out I had incorrect content-type set in Postman on the object being posted. Needed to be set as: application/json; charset=UTF-8
  • 调用upload.single('imagefile')什么都不做。 这相当于: exports.upload_image = function (req, res, next) { var upload = multer({ storage: multer.diskStorage({ destination: function (req, file, cb) { cb(null, 'public/cms/images/uplo ...
  • 事实证明,数据实际上是正确传输的,事实上我发送字符串让我相信这里有错误。 It turns out that the data was in fact being transferred properly, it was the fact that I was sending strings that led me to believe that there were errors here.
  • 因此,此请求是一个多部分文件上载,您感兴趣的文件是JSON文档。 查看快速多部分示例 。 你会想做类似的事情: 在req.files.updates.path读取connect为您保存的文件 使用JSON.parse将JSON数据解析为对象 So this request is a multipart file upload where the file you are interested in is a JSON document. Check out the express multipart exa ...
  • 第一个问题,编码必须与你的Express解析相匹配(在这种情况下,它不是multipart/form-data而是application/json , 'application/vnd.api+json' ,以及application/x-www-form-urlencoded删除你指定修复的编码类型。 其次,响应将是一个简单的JSON对象: { "message": "Post saved" } First question, the encoding must match what you h ...
  • 因此,在深入研究这个问题(前一段时间)后,我注意到IE8和IE9上的content-type标题都是空的。 因为empty不是默认值,所以我检查了是否有什么东西干扰了我的XDomainRequest设置,我发现jQuery-ajaxTransport-XDomainRequest正在改变xdr.contentType,将其设置为“”(空)。 我为此问题创建的解决方案是Express.js中间件,用于设置/覆盖对特定路由的请求的内容类型标头。 这是一个用法示例: var express = require(' ...
  • 如果您希望/specialRequest的请求体的大小有限但未解析,则可以使用bodyParser.raw() 。 在这种情况下, req.body将是一个按req.body包含请求主体的Buffer实例(未解析,但如果它被表示为gzip压缩或收缩数据,它将被夸大;可以通过其选项禁用此行为)。 您需要在插入bodyParser.urlencoded()中间件之前声明它: app.post('/specialRequest', bodyParser.raw({ limit : 123, type : '*/* ...
  • 我猜你在public/目录中有一个名为index.html的文件,这是在请求/时会得到的文件,因为这是express.static()默认执行的操作。 您可以禁用该行为,因此请求将传递给您的/ handler: app.use(express.static(path.join(__dirname, 'public'), { index : false })); 这在此处记录 。 或者,您可以通过在静态中间件之前声明请求来确保请求命中/ handler: app.get('/', function (req ...
  • body-parser模块当前不提供multipart/form-data解析器。 为此你需要像multer , multer / connect-busboy , multiparty或者formidable 。 The body-parser module currently does not a provide a multipart/form-data parser. For that you will need something like multer, busboy/connect-busbo ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)