I'm working on a PowerShell solution to scrape some pages in SharePoint (2013) Site Settings and I'm stuck on how to reference a ModalDialog that pops up during the scrape. Any suggestions how to do this?
I'm looking to pull the data from the input boxes and then click "Cancel" to return to the previous page.
The link that calls the modal is:
<td class='ms-authoringcontrols'>
<table cellspacing='0' cellpadding='0' border='0' class='ms-authoringcontrols'>
<a id="ctl00_PlaceHolderMain_editBB1" onclick="OpenBestBet('https:\u002f\u002www.example.com\u002fsites\u002fusa\u002fproductqualitysupport\u002fPages\u002fdefault.aspx'); return false;" href="#BestBet">Edit</a>
</table>
</td>
The JS function that opens the modaldialog is:
function OpenBestBet(bestBetUrl)
{
// make up the url to send to the BestBet page
bestBetUrl = bestBetUrl?escapeProperly(bestBetUrl):bestBetUrl;
var addedBestBets = document.forms[0].elements['ctl00_PlaceHolderMain_bestBet'].value ;
var keyword = escapeProperly(document.forms[0].elements['ctl00_PlaceHolderMain_keyword'].value);
var gotoUrl =
addQueryParametersToUrl('BestBet.aspx',['u','k','a'],[bestBetUrl,keyword,addedBestBets]);
var dialogOptions = {width:500, height:450};
SP.SOD.executeFunc('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', function() { SP.UI.ModalDialog.commonModalDialogOpen(gotoUrl,dialogOptions,AddBestBetCallback,[addedBestBets]); });
}
This is what it looks like on the page:
And the body tag of the modaldialog starts with:
<body>
<form method="post" action="BestBet.aspx?u=https%3a%2f%2fwww.example.com%2fsites%2fusa%2fproductsupport%2fPages%2fdefault.aspx&k=PQSS&IsDlg=1" onsubmit="javascript:return WebForm_OnSubmit();" id="BestBet">
<div class="aspNetHidden">
<input type="hidden" name="__REQUESTDIGEST" id="__REQUESTDIGEST" value="0xOBFUSCATED,29 Aug 2014 20:57:46 -0000" />
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/OBFUSCATED=" />
</div>
<script type="text/javascript">
//<![CDATA[
I'm using PowerShell 3.0, Net.WebClient, application.internetexplorer object, and also have HtmlAgilityPack but I'm not able to figure out how to reference the modaldialog. Any help would get great! Thanks
Ultimately, I was able to open and close the Modal window in Selenium but didn't take the time to figure out how to scrape values from it using Selenium.
Using PowerShell I wasn't able to access any part of the Modal, but when checking the source code of the Modal window I noticed the full URL in the header and was able to construct the URL from information on the parent page. This allowed me to launch another IE instance in PS, open the URL not in Modal mode, scrape the content, and close the window.
The URL construction was a little tricky with Unicode encoding and URI Data encoding, but I got it worked out. I hope others find this helpful.
Related
I'm using ASP.NET web forms and i need to post data to an iframe, the problem is that in web forms I have the main form tag(form1), so i need another form tag(form2), to post data to the iframe that is in the main form1.
Basically i have this:
<form method="post" id="form2" action="http://localhost:58903/WebForm1.aspx" target="webApp">
<input type="hidden" name="ValidationUserName" value="david" />
<input type="hidden" name="ValidationTokenId" value="13123132132" />
<button type="submit">Send info to inner iframe</button>
</form>
<form id="form1" runat="server">
<iframe id="webApp" name="webApp" src="http://localhost:58903/WebForm1.aspx" style="width: 800px; height: 800px;"></iframe>
</form>
With this approach in open a new tab, if i put the iframe outside it works ok, but if i do this the layout is changed and i don't want this.
Is this possible?
If all the forms are in the same domain you should not work with iframes.
What exactly are you trying to get here? didn't realize completely
Done it, it was missing the "name" attribute in the <form> tags.
I'm not sure what to put in for href:\ Should I reference a mailhandler.php or use a mailto: command? Or is there something better?
<h3 class="margin-bot">Newsletter!</h3>
<form id="subscribe-form" name="sibscribe" method="post">
<label><input class="subscribetext" type="text" onFocus="if(this.value =='Enter E-mail:' ) this.value=''" onBlur="if(this.value=='') this.value='Enter E-mail:'" value="Enter E-mail:" name="keyword" /></label>
<a onClick="document.getElementById('subscribe-form').submit()" class="button" href="#">subscribe</a>
</form>
I think it is meant for the site to which you get after pressing the subscribe button. Preferably the page the form was implemented in (for example to return to the index.html).
You can try it by testing it here on jsfiddle (http://jsfiddle.net). Just put an URL in the field where now is the # and after pressing subscribe you will see that you'll be redirected to that page.
I'm using Magento CE 1.7.
I created a CMS page to add 'Terms Of Use' to it and at the bottom of the page I added a simple "Accept Terms" submit form to have the customers agree to the terms before they can access the page I want them to access. Here's the code.
<form action="url-to-go-to.html" method="GET" onsubmit="return checkCheckBox(this)">
I accept: <input type="checkbox" value="0" name="agree">
<input type="submit" value="Continue">
<input type="button" value="Exit" onclick="document.location.href='BACKTOWHAT.html';">
</form>
<script type="text/javascript">
<!--
function checkCheckBox(f){
if (f.agree.checked == false )
{
alert("Please tick the box to continue");
return false;
} else
return true;
}
-->
</script>
The only problem I have is that in I can only get it to work by entering the URL to the page I want them to be redirected to. i.e.
<form action="domainname.com/shop.html"> <!-- store section to go to -->
/* and the same goes for */
onclick="document.location.href='domainname.com';"> <!-- back to storefront -->
I wanted to use something else rather than the URL but I'm not sure how to do it. I thought using something like this would work.
<form action="<?php echo $this->_redirect('shop.html'); ?>" method=.... >
but it didn't.
I believe if this has been within a .phtml file it would've worked but I'm working with a simple CMS page and I know magento functions work in CMS pages but I don't know a function that would work for this purpose.
Ok, I figured it out after testing a bit more. (I'm still learning how to code)
It's quite simple, the form action should be like this instead.
<form action="{{store direct_url='shop.html'}}" method=..... >
and to redirect back to the store front on "exit" this is what worked.
onclick="document.location.href='{{store direct_url=' '}}
This worked perfectly. hope it helps others.
I'm new to tumblr and am trying to implement Search in a custom theme. I have:
<form action="/search" method="get" id="search-form">
<input type="text" name="q" class="query" value="" />
<input type="submit" value="Search" class="submit" />
<div class="clear"></div>
</form>
I have about a dozen posts. Whenever I search for anything in any post, Tumblr always returns no search results. I feel like I'm missing something. Am I to implement or set any configuration anywhere else in the theme? What else is needed to implement search in a user's Tumblr theme?
Thanks!
Here's the solution I use. Put this into the <head> of your code:
<script type="text/javascript">
<!--
function handleThis(formElm)
{
window.location="/tagged/"+formElm.number.value+"";
return false;
}
-->
</script>
And place this where you want the search box to appear:
<form onsubmit="return handleThis(this)">
<div class="submit"><input type="submit" value="{lang:Search}" name="Submit"/></div>
<div class="input"><input onfocus="this.value=''" onblur="if(this.value=='') this.value='Search. Then hit enter.';" type="text" value="{lang:Search}. Then hit enter." name="number"/></div>
</form>
Use CSS to style as you wish. This will search your tags only, but unlike the regular Tumblr search it works.
I was getting no results when my blog was password protected. I removed the password protection from Tumblr Dashboard > settings > blog name > password and it started returning results again.
I have a login form written in PHP and each time I start the browser and go to the respective page, the first field of the form is this:
<input type="hidden" name="PHPSESSID" value="session_id_code" />
If I close the window, but I don't restart the browser, this doesn't happen. Any idea what's happening and why?
Thanks!
Form's code:
<?php
if (condition) {
?>
<form method="post" action="">
<dl>
<dt>Email:</dt>
<dd><input type="text" name="useremail" /></dd>
<dt>Password:</dt>
<dd>
<input type="password" name="userpass" /></dd>
<dt class="dt-buttons"><input type="submit" name="button_login" value="Login" class="button" /></dt>
</dl>
<input type="hidden" name="formkey" id="formkey" value="224ca00155w2fcda8906e1e40af03a71" />
</form>
<?php
}
?>
The form is simple HTML and is not dynamically generated.
EDIT2:
As I was saying, when I access the page for the first time after I started the browser, this thing happens. If I refresh the page afterwards, the hidden field doesn't show up.
Is it possible to have something to do with the SSL certificate? And if yes, why some pages/forms behave like this and some don't?
Sounds like you've got trans_sid enabled (transparent session id). Using trans_sid can be a security issue, especially if your site links to external content, or you allow link sharing - it lets a user's session ID leak out as part of the URL, meaning the session is highly vulnerable to hijacking.