3


以前にこの質問をして、何度も解決しようとしましたが、うまくいきませんでした。
JavaScript の経験がほとんどないプログラマーではないので
、ページ上のすべての画像を、画像のリンクが指す元の (フルサイズの) 画像に置き換えるのに役立つブックマークレットまたは同様のものが欲しいです。たとえば、リンクされた画像をクリックすると、フルサイズの画像が表示されますが、そのフルサイズの画像をページに表示したいです。

サイトのコードの例を次に示します。

<a href="http://www.diyphysics.com/wp-content/uploads/2012/02     Multiplier_schematic.jpg">
<img class="aligncenter wp-image-627" title="Multiplier_schematic" src="http://www.diyphysics.com/wp-content/uploads/2012/02/Multiplier_schematic-1024x205.jpg" alt="Schematic of Dual-Polarity High-Voltage Cockroft-Walton Multiplier by David and Shanni Prutchi" width="614" height="123"/>
</a>

私はそれが欲しい:

<img class="aligncenter wp-image-627" title="Multiplier_schematic" src="http://www.diyphysics.com/wp-content/uploads/2012/02/Multiplier_schematic.jpg" alt="Schematic of Dual-Polarity High-Voltage Cockroft-Walton Multiplier by David and Shanni Prutchi"/>

幅と高さの制限が解除されました。

例として、このサイト
http://www.pocketmagic.net/?p=802
には、リンクとして表示される小さな低解像度の画像がたくさんあります。ブックマークレットでこれらすべての画像を高解像度の画像に置き換えてください。それらは指摘されています。このようにして、ページ全体を保存したり、エクスポートしたりできます...

ありがとうございました !

編集: 1. @Frosco、試してみましたが、JS に関する知識がほとんどないため、どこにも行けませんでした。
2. @PhD、javascript: プロトコルを使用した bookmarlet である必要があります。ユーザー指向であり、Web 開発者向けではありません。

解決済み: ジョンのおかげで、私はそれを理解しました。

興味のある方のために、JS ブックマークレットを次に示します。

javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.3.2",function($,L){$('a img').each(function(index) {    var currentElement= $(this);    var anchor = currentElement.parent();    var highResSource = anchor.attr("href");    var newImage = "<img src='" + highResSource + "'/>" +"</div>";    anchor.html(newImage);});});
4

2 に答える 2

0

このようなものから始める必要があります:

$('a img').each(function(index) {
    var currentElement= $(this);
    var anchor = currentElement.parent();
    var highResSource = anchor.attr("href");
    var newImage = "<img src='" + highResSource + "'/>";
    anchor.html(newImage);
});​
于 2012-07-05T02:46:31.220 に答える
0

.unwrap()を試すことができます:

$('img').each(function() {
   var $this = $(this);
   if ($this.attr('src') === $this.parent('a').attr('href')) {
       $this.unwrap();
   }
});
于 2012-07-05T02:49:49.353 に答える