Javascript 在html中连接Js
我在这里使用fancybox:Javascript 在html中连接Js,javascript,php,html,Javascript,Php,Html,我在这里使用fancybox: @foreach($galleries as $gallery) <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3"> @if($id != null) <a id="{{$id}}" class="fancybox-buttons img-holder small-img" rel="gallery" title="" data-fancybo
@foreach($galleries as $gallery)
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
@if($id != null)
<a id="{{$id}}" class="fancybox-buttons img-holder small-img" rel="gallery" title="" data-fancybox-group="button"
href="/storage/galleries/{{$gallery->image}}">
@else
<a id="{{$gallery->id}}" class="fancybox-buttons img-holder small-img" rel="gallery" title="{{$gallery->id}}" data-fancybox-group="button"
href="/storage/galleries/{{$gallery->image}}">
@endif
<img src="/storage/galleries/{{$gallery->image}}" alt="img">
</a>
</div>
@endforeach
@foreach($gallery作为$gallery)
@如果($id!=null)
@endforeach
我有一个fancybox函数,afterload选项得到了如下共享链接:
afterLoad : function() {
id = this.title;
this.title =
'<a href="https://twitter.com/intent/tweet?url={{ urlencode(Request::fullUrl())}}/(id variable)" class="btn btn-tw btn-small"><i class="fa fa-twitter right-fa"></i> Share</a>';
}
'<a href="https://twitter.com/intent/tweet?url={{ urlencode(Request::fullUrl()) }}/'+id+'" class="btn btn-tw btn-small"><i class="fa fa-twitter right-fa"></i> Share</a>'
afterLoad:function(){
id=这个名称;
此.title=
'';
}
我想将这个变量id添加到href中,如果php还有其他解决方法,那也太好了我发现答案如下:
afterLoad : function() {
id = this.title;
this.title =
'<a href="https://twitter.com/intent/tweet?url={{ urlencode(Request::fullUrl())}}/(id variable)" class="btn btn-tw btn-small"><i class="fa fa-twitter right-fa"></i> Share</a>';
}
'<a href="https://twitter.com/intent/tweet?url={{ urlencode(Request::fullUrl()) }}/'+id+'" class="btn btn-tw btn-small"><i class="fa fa-twitter right-fa"></i> Share</a>'
“”
您可以像这样包含id
:
'<a href="https://twitter.com/intent/tweet?url={{ urlencode(Request::fullUrl())}}/' + id + '" class="btn btn-tw btn-small"><i class="fa fa-twitter right-fa"></i> Share</a>';
”;
@MehravishTemkar我试过了,但没有成功,但我现在用“{urlencode(Request::fullUrl())}/'+id+”class=“btn btn tw btn small”>共享”谢谢你:)