2010-12-02 5 views
0

Ich analysiere ein Formular von einer anderen meiner Websites mit einem PHP-Proxy. Es funktioniert gut, aber die Formularaktion und img src der Absenderschaltflächen-URLs sind relativ. Wie kann ich die vollständige http // www.domain.com/vor jeder der URLs im Formular voranstellen?Ändern Sie Aktion und Bild Quell-URLs mit jQuery

Edit:

Hier ist die Codeform einmal gefüttert durch auf die neue Domain:

<div style="display: none;" id="SubscribeForm" class="newform"> 

      <h5>Subscribe to our newsletter</h5> 

      <form action="/CampaignProcess.aspx?ListID=27057" method="post" onsubmit="return checkWholeForm93426(this)" name="catemaillistform93426"> 

       <div class="form"> 

       <div class="item"> 

       <label for="CLFullName">Full Name</label> 

       <br /> 

       <input type="text" maxlength="255" id="CLFullName" name="FullName" class="cat_textbox_small" style="background-color: #ffffa0;" /> 

       </div> 

       <div class="item"> 

       <label for="CLEmailAddress">Email Address</label> 

       <br /> 

       <input type="text" maxlength="255" id="CLEmailAddress" name="EmailAddress" class="cat_textbox_small" style="background-color: #ffffa0;" /> 

       </div> 

       <div class="item"> 

       <label>Enter Word Verification in box below</label> 

       <br /> 

       <div class="captchaimg"><img src="/captchahandler.ashx?ID=22791bf65054422cadeb4aea9390cfaa&amp;Color=DimGray&amp;ForeColor=White&amp;Width=160" alt="Captcha Image" /></div> 

    <input id="CaptchaV2" class="cat_textbox" type="text" name="CaptchaV2" style="width:160px" /> 

    <input id="CaptchaTV2" type="text" name="CaptchaTV2" style="display:none;" /> 

    <input id="CaptchaHV2" type="hidden" value="22791bf65054422cadeb4aea9390cfaa" name="CaptchaHV2" /> 



       </div> 

       <div class="item"> 

       <p>We respect your privacy and will never share your details.</p> 

       </div> 

       <div class="item"> 

       <input type="image" src="/images/submit-button-white-bg_07.gif" id="catlistbutton" value="Subscribe" class="cat_button" /> 

       </div> 

       </div> 

       <script type="text/javascript" src="http://testsite.businesscatalyst.com/CatalystScripts/ValidationFunctions.js"></script> 

       <script type="text/javascript">function checkWholeForm50598(theForm){var why = "";if (theForm.EmailAddress) why += checkEmail(theForm.EmailAddress.value);if (theForm.CaptchaV2) why += isEmpty(theForm.CaptchaV2.value, "Enter Word Verification in box below"); if (why != ""){alert(why);return false;}theForm.submit();return false;}</script> 

      </form> 
</div> 

und hier ist die jQuery ich verwende, um zu versuchen und die Aktion URL zu ändern:

jQuery(document).ready(function($) { 
    $('form').each(function(index) { 
    var urls = $(this).attr('action'); 
    var dom = 'http://www.sampleurl.com'; 
    $(this).attr('action',dom+urls); 
    }); 
}); 

Alle anderen jQuery-Funktionen funktionieren gut auf der Seite, daher weiß ich, dass dies kein Problem mit jQuery selbst ist.

+0

Wenn es ** wirklich deine ** Seite ist, nimm ** deine ** Quellen und lege sie in ein anderes Projekt, ohne zu analysieren. – zerkms

+0

Was meinen Sie mit "Parsen eines Formulars von einer anderen meiner Websites"? Kannst du es ausarbeiten? – Lee

+0

Ich weiß nicht, ob das helfen wird, aber ich musste in letzter Zeit etwas Ähnliches machen: http://StackOverflow.com/questions/4110954/how-to-use-php-to-submit-a-form-and- retrieve-a-file-from-another-site – jeremysawesome

Antwort

0

gut Beginn der ursprünglichen URL zu lesen

$('img').each(function(index) { 
    var urls =$(this).attr('src'); 
    var dom = 'http://domain.com'; 
    $(this).attr('src',dom+urls); 

    }); 

, die alle Bild Urls ändern könnte eine andere Art und Weise sein, aber das funktioniert genauso gut

Kasse hier

http://www.jsfiddle.net/LewEB/

+0

Danke Breezer. Aber was ist mit der Aktion URL? – Jackson

+0

ändern Sie einfach den Selektor zu Formular und attr zu Aktion – Breezer

+0

Verdammt! Scheint nicht zu funktionieren :( – Jackson