Php 使用jQuery更改操作和图像src url

Php 使用jQuery更改操作和图像src url,php,javascript,jquery,Php,Javascript,Jquery,我正在使用php代理解析来自另一个站点的表单。它工作正常,但是表单操作和提交按钮url的IMGSRC是相对的。如何在表单中的每个url前面预先添加完整的http//www.domain.com/ 编辑: 以下是表单代码,一旦输入到新域: <div style="display: none;" id="SubscribeForm" class="newform"> <h5>Subscribe to our newsletter</h5>

我正在使用php代理解析来自另一个站点的表单。它工作正常,但是表单操作和提交按钮url的IMGSRC是相对的。如何在表单中的每个url前面预先添加完整的http//www.domain.com/

编辑:

以下是表单代码,一旦输入到新域:

 <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>

所有其他jQuery函数在页面上都运行良好,因此我知道jQuery本身没有问题。

我们开始阅读原始url

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

  });
这将更改所有图像URL 可能是另一种方式,但这同样有效

在这里结账


如果它真的是你的站点-获取你的源代码并将它们放在另一个项目中,而不进行任何解析。从我的另一个站点解析表单是什么意思?你能详细说明一下吗?我不知道这是否会有帮助,但我最近也做了类似的事情:好的,一个网站位于托管CMS Business Catalyst上,它包含动态生成的元素,如图像验证码。所以我不能把源代码放到我的服务器上。这些元素将不再起作用。这是一份订阅表,我会放在我的wordpress博客上。谢谢Breezer。但是操作url呢?只需将选择器更改为form,将attr更改为actionzer。编辑了我的原始问题。我刚刚测试了它,它工作得非常好。。。如果你使用firebug,你会看到它变得changed@Jackson-您可以通过添加这样的行警报$this.attr'action'看到它正在工作;
$('img').each(function(index) {
    var urls =$(this).attr('src');
    var dom = 'http://domain.com';
    $(this).attr('src',dom+urls);

  });