Buying JQuery on Str Replace

Discussion in 'Programming' started by bunbunx2, Aug 21, 2010.

  1. #1
    
    <html>
    <head>
    <script type="text/javascript" language="JavaScript">
    
    function changes() { 
    var content = document.getElementById('content');
    document.getElementById('content').innerHTML = "";
    } 
    </script>
    </head>
    <body>
    <a title="7" href="javascript:void(0);" onclick="javascript:changes();">Watch Mode</a>
    <div class="content">
    <iframe src="http://www.asoptimize.com/book.php?config=http://www.animeshippuuden.com/xml.php?url=http://video.ak.fbcdn.net/cfs-ak-snc4/48477/304/119168191466907_50238.mp4" frameborder="0" scrolling="no" width="480" height="412"></iframe>
    
    PART 2
    <iframe src="http://www.asoptimize.com/book.php?config=http://www.animeshippuuden.com/xml.php?url=http://video.ak.fbcdn.net/cfs-ak-ash2/48331/424/119168198133573_3975.mp4" frameborder="0" scrolling="no" width="480" height="412"></iframe>
    </div>
    
    </body>
    </html>
    
    Code (markup):
    I wanna have the function changes to do the following

    Get the content of div class content to a var e.g content
    content need a str replace , find string "asoptimize" , replace with "animeshippuuden"
    Set the content of div class content to void
    Set the content of div class content to var content ( the one after str replace)

    ANyone can provide me the working code by p.m will get $15 usd via paypal. please send me your paypal detail also. i will close this thread when the first working solution arrive, if not close means still available and valid.


    Paypal : $15 usd
     
    bunbunx2, Aug 21, 2010 IP
  2. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    are you by any means trying to update the content of the iframed page? i dont think that would be possible
     
    creativeGenius, Aug 21, 2010 IP
  3. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    Hi, I think this is what you're looking for:

    
    <html>
    <head>
    <script type="text/javascript" language="JavaScript" src="jquery-1.4.2.js"></script>
    
    <script type="text/javascript" language="JavaScript">
    jQuery(document).ready(function(){
    jQuery('iframe').each(function(){
    jQuery(this).attr('src',jQuery(this).attr('src').replace(/\basoptimize\b/mgi,'animeshippuuden'));
    });
    });
    </script>
    </head>
    .......................
    
    HTML:
    I've used latest uncompressed jQuery from here

    Of course it can be applied to .content.innerHTML:
    
    <html>
    <head>
    <script type="text/javascript" language="JavaScript" src="jquery-1.4.2.js"></script>
    
    <script type="text/javascript" language="JavaScript">
    jQuery(document).ready(function(){
    jQuery('.content').each(function(){
    jQuery(this).html(jQuery(this).html().replace(/\basoptimize\b/mgi,'animeshippuuden'));
    
    /*
    Uncomment to check the code
    alert(jQuery(this).html());
    */
    
    });
    });
    </script>
    </head>
    
    HTML:
    My opinion is that first variant is recommended - hope that's what's needed.
    The second changes innerHTML everywhere inside elements with class name "content".

    Let me know the result.
    Regards :)
     
    koko5, Aug 22, 2010 IP
  4. abmathur

    abmathur Member

    Messages:
    211
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    Code below will replace asoptimize with animeshippuuden and update the div when WATCH MODE will be clicked.

    <html>
    <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" language="JavaScript">
    $(document).ready(function(){
    		$("#change").click(function(event){	// initiate action on click
    			$(".content").html($(".content").html().replace(/asoptimize/g,'animeshippuuden')); // replace content recursively
    	});
    });
    </script>
    </head>
    <body>
    <a title="7" href="javascript:void(0);" id="change">Watch Mode</a>
    <div class="content">
    <iframe src="http://www.asoptimize.com/book.php?config=http://www.animeshippuuden.com/xml.php?url=http://video.ak.fbcdn.net/cfs-ak-snc4/48477/304/119168191466907_50238.mp4" frameborder="0" scrolling="no" width="480" height="412"></iframe>
    PART 2
    <iframe src="http://www.asoptimize.com/book.php?config=http://www.animeshippuuden.com/xml.php?url=http://video.ak.fbcdn.net/cfs-ak-ash2/48331/424/119168198133573_3975.mp4" frameborder="0" scrolling="no" width="480" height="412"></iframe>
    </div>
    </body>
    </html>
    HTML:
     
    abmathur, Aug 22, 2010 IP